This was written in dbpro slightly modified for being a utility outside of a bigger project of mine.
this code will load an image of anysize (could be a huge photo or a small 12x12 photo)
what size do you want? as long as your display mode is big enough this method will work from 640x480 default on regular screen resolution.
if you have a texture that is say 1024x768
and you need an image size of 200x200 boom done
if you have a texture that is say 10x176
and you want it to be 400x400 boom done
lol
anyways you get the idea and if you read threw there is a spot that will resave the image to your desired size
Rem Project: image resize
Rem Created: 8/23/2009 4:34:02 PM
Rem ***** Main Source File *****
rem written by sheldon macdonald
rem SMD3D Interactive (c)2009
rem modify and use at your own free will (no restrictions)
`**************************************************************************************
`+++++ READ THE TEXT BELOW TO UNDERSTAND WHAT YOU NEED TO CHANGE ++++++++++++++++++++++
`**************************************************************************************
sync on
sync rate 60
` this can be any supported picture format that works for dbpro
`and your picture can be anysize and this will rescale it.(small or bigger)
`you can expand on this and make it better eg.. make it copy to a new memblock instead...
file_to_resize$="anypicture.jpg"`if file doesnt exist it will fail
desiredwidth#=400`dont make this bigger then your display size
desiredheight#=400`dont make this bigger then your display size
`as long as your screen size is not smaller then your requested size this example will work
`again... there is better ways of doing this but this is 1 way that works.
dim newimage(400,400)` change this to the same size of your tiles (desired width and height)
gosub resizeimage` resizing and saving to image (1)
rem if you want to save the newly resized file then simply type this:
`***************************************************************************************
`save image "new_sized image.bmp",1`bitmap only ++++++++++++++++++++++++++++++++++++++++
`***************************************************************************************
`if image doesnt exist then this does nothing
if image exist(1)=0 then end
do
cls
paste image 1,0,0,0
ink rgb(255,0,0),0:set cursor 1,1:print "press escape to exit"
sync
loop
resizeimage:
if file_to_resize$="" then return
if file exist(file_to_resize$)=0 then return
if image exist(1)=1 then delete image 1
if memblock exist(1)=1 then delete memblock 1
load image file_to_resize$,1,1
make memblock from image 1,1
delete image 1
size=GET MEMBLOCK SIZE(1)
pos=0
Width#=memblock DWORD(1,0):Height#=memblock DWORD(1,4):depth=memblock dword(1,8)
pos=12
if depth=32 then cnt=4
if depth=24 then cnt=3
if depth=16 then cnt=2
if depth=8 then cnt=1
counter=12
scx#=desiredwidth#/width#
scy#=desiredheight#/height#
sx#=0
sy#=0
for y1=1 to height#
sy#=sy#+scy#
for x1=1 to width#
sx#=sx#+scx#
for ty=0 to scy# step 1:for tx=0 to scx# step 1:gosub drawspot:next tx:next ty
counter=counter+cnt
next x1
sx#=0
next y1
rem done
`now paste image and get it
for x=1 to desiredwidth# step 1
for y=1 to desiredheight# step 1
ink newimage(x,y),0
dot x-1,y-1
next y
next x
if image exist(1)=1 then delete image 1
get image 1,0,0,desiredwidth#,desiredheight#
rem done
return
drawspot:
a1=int(sx#-tx)
b1=int(sy#-ty)
if a1<1 then a1=1
if a1>desiredwidth# then a1=desiredwidth#
if b1<1 then b1=1
if b1>desiredheight# then b1=desiredheight#
newimage(a1,b1)=memblock DWORD(1,counter):
return
SMD3DInteractive