Small image distortion

Archives Forums/BlitzMax Bug Reports/Small image distortion

Drackbolt(Posted 2009) [#1]
Hello there,
I've noticed three things about using small images (small as in, 5x5, 4x6 pixels, etc) in Blitzmax. I need to use these little guys because my game is very much a retro design and I don't have enough screen real-estate to over-size them. I use the D3D7Max2D framework (the problems with OpenGL are much worse). I'm listing all three problems here because I'm guessing they're related.

The first is that some of these images will not display properly if they are in square dimensions. An image at 4x6 might display fine, but one at 5x5 will cut off an entire column of pixels on the right. This occurs on almost all video cards.

The second is that some video cards can't display small images properly at all. This usually seems to happen with integrated video cards. The images might have columns or rows shifted and generally are so mangled (sometimes as if they've been scaled badly) they can't be read.

The last problem is that some images on certain operating systems get shifted one pixel. For instance, I use 10x10 bitmaps for numbers on moving counters, and on an XP computer it displays in the right place, but on a Window 7 computer it displays the images just out of place. If I correct my code to fix one, the problem just happens in the other OS.

Any thoughts? Is this just something to live with? If no one else has seen these issues, I'll try to get some custom code worked up. Unfortunately most of these sporadic and computer-dependent so it may be hard to replicate.


TaskMaster(Posted 2009) [#2]
It is caused by the way BlitzMax handles images internally. When you load a 5x5 pic, BlitzMax loads it as a 8x8 (power of 2 sizes). Then when it is drawn, it gets scaled.

See this thread:

http://www.blitzmax.com/Community/posts.php?topic=85478#969578

for when I noticed this a couple months ago. The DrawImageArea function solves the problem.


Drackbolt(Posted 2009) [#3]
Awesome! I didn't even know about DrawImageArea. I'll try it out right away. Although, since there must be a speed hit, I think I might just reformat all my images to account for the power-of-2 sizing you mentioned instead, and just leave blank space on the outsides. Thanks a lot for the explanation.


TaskMaster(Posted 2009) [#4]
There isn't really much of a speed hit for using this function, as it is doing almost the exact same thing the built in BlitzMax commands do.