Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » A5 Bitmap Edges

Credits go to Edgar Reynaldo for helping out!
This thread is locked; no one can reply to it. rss feed Print
A5 Bitmap Edges
James Bunting
Member #30
April 2000
avatar

When I tile 32x32 pixel bitmaps at 32 pixel intervals I am getting a gap of 1 pixel on the right and lower edge of each bitmap.

I am using al_draw_bitmap()

...
al_draw_bitmap( this->map.tileset.tiles[tile].image, x * TILE_W, y * TILE_H, 0);
...

Is this normal behaviour for A5? Any ideas?

Edgar Reynaldo
Member #8,592
May 2007
avatar

Are you sure your bitmaps are 32x32? It would be hard to screw that up though....

Are you sure TILE_W and TILE_H are correct as well? That would be hard to screw up too....

al_draw_bitmap only takes x and y, so if the width and height are wrong, then it is either that the bitmap is the wrong size, or you are putting it in the wrong spot.

Do you get the same problem with al_draw_scaled_bitmap?

James Bunting
Member #30
April 2000
avatar

Thanks for the input. I worked it out in the end.

The tile images were originally imported using al_draw_pixel() which misaligned the pixels. Importing the tiles again using al_put_pixel() fixed it.

James

Edgar Reynaldo
Member #8,592
May 2007
avatar

James Bunting
Member #30
April 2000
avatar

Yes. Same loop, same bounds, same code. draw_pixel() shifted all of the pixels to the left -1 and top -1 thus offsetting the bitmap and totally missing the right and bottom lines.

The A5 docs state that this function may not put pixels extactly where specified although I just picked up the function by name and did not read the function's manual entry.

James

Matthew Leverton
Supreme Loser
January 1999
avatar

The A5 docs state that this function may not put pixels extactly where specified

It does draw them exactly where specified, but it may not be where you expect them to be if you don't understand how the graphics in 5.0 work.

Pixel centers are at (+0.5,+0.5) so if you use al_draw_pixel() to draw full pixels on an integer grid, you'd need to add 0.5 to the coordinates.

Dizzy Egg
Member #10,824
March 2009
avatar

Pixel centers are at (+0.5,+0.5) so if you use al_draw_pixel() to draw full pixels on an integer grid, you'd need to add 0.5 to the coordinates

Why? See, I'm still scared to leave 4.2...

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

Thomas Fjellstrom
Member #476
June 2000
avatar

Dizzy Egg said:

Why? See, I'm still scared to leave 4.2...

That's how the hardware does it. When you render a pixel or a line or what have you with normal accelerated operations, the hardware checks to see if the centre of a pixel is filled before actually filling it.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Elias
Member #358
May 2000

And it becomes especially important when you use multisampling. Which can look much better than the old-style pixel-by-pixel look you get in A4.

--
"Either help out or stop whining" - Evert

Go to: