Posted: 19th Jan 2004 21:17
Here is a memblock solution to rotating images in DBPro. It will rotate a square image by 90 180 and 270 degrees.

imgin is the original image.
imgout is the image to create.

+ Code Snippet
function rotate_image(imgIn,imgOut,Rotation)
Dim IMGDATA(1024,1024,4) as byte

make memblock from image 1,ImgIn
Width=memblock dword(1,0)
Height=memblock dword(1,4)
Depth=memblock dword(1,8)

bCount=12
for n=1 to width
for m=1 to height
for o=1 to Depth/8
IMGDATA(n,m,o)=memblock byte(1,bCount)
bCount=bCount+1
next o
next m
next n

bCount=12

If Rotation=270
for n=1 to width
for m=1 to height
for o=1 to Depth/8
write memblock byte 1,bCount,IMGDATA(m,(width-n),o)
bCount=bCount+1
next o
next m
next n
endif

If Rotation=90
for n=1 to width
for m=1 to height
for o=1 to Depth/8
write memblock byte 1,bCount,IMGDATA((height-m),n,o)
bCount=bCount+1
next o
next m
next n
endif

If Rotation=180
for n=1 to width
for m=1 to height
for o=1 to Depth/8
write memblock byte 1,bCount,IMGDATA((width-n),(height-m),o)
bCount=bCount+1
next o
next m
next n
endif

make image from memblock imgOut,1
delete memblock 1

undim IMGDATA()
endfunction