AutoMidHandle

BlitzMax Forums/BlitzMax Programming/AutoMidHandle

Pit-le-rouge(Posted 2005) [#1]
Hi everybody.

Something I don't understand.
I created a PNG image.
If I use, in my program, the instruction "AutoMidHandle True", my image seems to be as filtered (one pixel line become two or three pixels line for example).
If I don't use "AutoMidHandle True", all is OK. My image is exactly how I drawed it.

Can someone explain this ?


tonyg(Posted 2005) [#2]
I don't see any difference using Max.png.
Have you got any example code?


Pit-le-rouge(Posted 2005) [#3]
Tonyg,

I just discovered why !
My image had a odd height (41 pixels). Now the height is 42 pixels AND ALL IS OK !!!
So, it seems that when the height of an image is odd, if you use automidhandle, your image is something as "rendered"...
I suppose this is because if you divide by 2 an odd number, you don't have an integer result...
Can we consider this as a bug ?
What's your opinion ?


Hotcakes(Posted 2005) [#4]
I don't understand what you're saying, but if it's that a picture of odd height (or presumably odd width) is being displayed improperly when AutoMidHandle is used on it, then yes, I'd say report it as a bug.


JazzieB(Posted 2005) [#5]
It's not a bug.

What happens is that you can draw images anywhere on screen, including non-integer pixel locations. With images of an odd number of pixels the mid point will be something like 50.5 (for an image of width 101, for example). When it's drawn it will also be sitting on a pixel location of <something>.5, so the image is filtered or interpolated.

To get around this...

1. Make sure your images have even dimensions (as already discovered).

2. This may only be the case when the blending mode is set to ALPHABLEND, so use SOLIDBLEND when drawing these images, if you can.

3. Set the image handle manually.

4. Subtract (or add) .5 from your screen positions when drawing these images.


Pit-le-rouge(Posted 2005) [#6]
Thanks JazzieB !