A5 Bitmap Edges
James Bunting

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

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

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

So did you just not draw all the way to the edge of the source bitmaps then?

Anyway, glad it's sorted out.

James Bunting

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

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

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...

Thomas Fjellstrom
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.

Elias

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.

Thread #609807. Printed from Allegro.cc