Well here is a demo...
You can see even with slice across and slice down set to "1"
there is distortion...
When you run it,
it displays the original image for a second,
then the pieced together sprite...
The KEYCONTROLS are:
SPACEKEY = refresh current pattern
UPKEY = increase slices Y
DOWNKEY = decrease slices Y
LEFTKEY = decrease slices X
RIGHTKEY = increase slices X
You can clearly see distortion at 1x1...
You can clearly see the distortion get worse as you
increase away from a power of two, and get better as you
approach a power of two... But even at a power of 2,
the distortion is clearly noticable.
My system is Windows 2000 SP4+
2GB system RAM, 3.2GHz Hyperthreaded, nVidia 6600 8xAGP
The code included in the download is :
sync on `we are in control
sync rate 0 `controling as fast as we can
sync `dumping buffer
sliceX=1 `default sliceX
sliceY=1 `default sliceY
filename$="test06.png" `mosaic image
blank$="blank06.png" `solid red image
do
cls rgb(0,0,0) `blank screen to black
sync `show blank screen
if sprite exist(1) then delete sprite 1 : delete image 1 `if we did this before delete previous images
create animated sprite 1,blank$,sliceX,sliceY,1 `make RED sprite and image and slice them
load image filename$,1,1 `load real image
set sprite 1,0,0 `no backtarce, no transparency
width = sprite width(1) `width of full sprite
height = sprite height(1) `height of full sprite
w = int(sprite width(1)/sliceX) `width of each frame
h = int(sprite height(1)/sliceY) `height of each frame
paste image 1,0,0 `paste the original real image ( always pixel perfect )
text 257,5, "original" `original image text
sync `draw to screen
sleep 1000 `wait 1 second
cls rgb(0,0,0) `clear screen
`draw frames of sprite in pattern that aproxiamtes the original image
for y = 0 to sliceY-1
for x = 0 to sliceX-1
set sprite frame 1,(y*sliceX)+x
paste sprite 1,x*w,y*h
next x
next y
` sprite text ( defines X/Y frames )
text 257,5, "SliceX: "
text 257,17, " "+str$(sliceX)
text 257,29, "SliceY: "
text 257,41, " "+str$(sliceY)
sync `draw to screen
`wait for key
do
if leftkey() `decrease across
dec sliceX
if sliceX < 1 then sliceX = 1
exit
endif
if rightkey() `increase across
inc sliceX
if sliceX > width then sliceX = width
exit
endif
if downkey() `decrease down
dec sliceY
if sliceY < 1 then sliceY = 1
exit
endif
if upkey() `increase down
inc sliceY
if sliceY > height then sliceY = height
exit
endif
if spacekey() `refresh
exit
endif
loop
loop
end
Anyone who can improve upon this demonstration please do...
Comments welcome...
Fixes needed...
================
-Dejunai
================