I did not mean BASE 2 I meant POWER of 2 sorry
This will resize a texture to the nearest Power of 2 size. It could be useful for 3DWS or ther things? Anyway, create a new project and copy the code below into it. Then, press F4 to compile the code into an exe. Now, whenever you drag a BMP JPG TGA PNG or DDS image onto the EXE it will be resized to the nearest base 2 number. Yay!
Automatically resizes to the nearest number:
sync on
sync rate 0
autocam off
set text font "arial"
set window on
set window title "Texture Sizer"
File$=cl$()
l=len(file$)
file$=Left$(File$,l-1)
l=Len(File$)
File$=Right$(File$,l-1)
File$=Lower$(File$)
if right$(File$,4)=".bmp" or right$(File$,4)=".jpg" or right$(File$,4)=".tga" or right$(File$,4)=".png" or right$(File$,4)=".dds"
load image File$,1
sprite 1,0,0,1
color backdrop 0
Avg=(Sprite Width(1)+Sprite Height(1))/2
Size=16
if Avg<=Size
size sprite 1,Size,Size
endif
if Avg>=Size and Avg<=Size+Size/2
size sprite 1,Size,Size
endif
Size=32
if Avg>=Size and Avg<=Size+Size/2
size sprite 1,Size,Size
endif
Size=64
if Avg>=Size and Avg<=Size+Size/2
size sprite 1,Size,Size
endif
Size=128
if Avg>=Size and Avg<=Size+Size/2
size sprite 1,Size,Size
endif
Size=256
if Avg>=Size and Avg<=Size+Size/2
size sprite 1,Size,Size
endif
Size=512
if Avg>=Size
size sprite 1,Size,Size
endif
set current bitmap 0
sync : paste sprite 1,0,0 : get image 2,0,0,Sprite width(1),sprite height(1) : sync
save image left$(File$,len(File$)-4)+"_size"+right$(File$,4),2
exit prompt "Image saved with a "_size" at the end.","SAVE COMPLETE"
delete image 1
delete image 2
delete sprite 1
end
else
exit prompt "Not a valid image file","FILE ERROR"
end
endif
Allows you to choose the number:
sync on
sync rate 0
autocam off
set text font "arial"
set window on
set window title "Texture Sizer Choose"
File$=cl$()
l=len(file$)
file$=Left$(File$,l-1)
l=Len(File$)
File$=Right$(File$,l-1)
File$=Lower$(File$)
if right$(File$,4)=".bmp" or right$(File$,4)=".jpg" or right$(File$,4)=".tga" or right$(File$,4)=".png" or right$(File$,4)=".dds"
sync : input "Type in a size for your image: ",Size : sync
load image File$,1
sprite 1,0,0,1
color backdrop 0
size sprite 1,size,size
set current bitmap 0
sync : paste sprite 1,0,0 : get image 2,0,0,Sprite width(1),sprite height(1) : sync
save image left$(File$,len(File$)-4)+"_size"+right$(File$,4),2
exit prompt "Image saved with a "_size" at the end.","SAVE COMPLETE"
delete image 1
delete image 2
delete sprite 1
end
else
exit prompt "Not a valid image file","FILE ERROR"
end
endif
Comments?