I am displaying transparent images on top of another "underneath" image.
In this case the bottom (solid) image is a chessboard grid and the top image is a lion (transparent):
=
The reason is to show transparency areas much better as typically you would not see which areas are transparent.
The problem is, bitmaps can be any size in dimensions, so the grid would also need to be the same size as the bitmap.
A dirty approach if you like would be to create a larger version of the chessboard grid above to a size such as 2000x2000, then depending on the size of the bitmaps you are working with you could resize the canvas of the grid to match. This is not ideal because it means storing the large chessboard grid bitmap with your application, and then it means resizing it which may not give the correct results depending on aspect ratio etc.
The correct approach I feel would be to render the chessboard grid programmatically, something like:
procedure RenderGrid(Source: TBitmap; Height, Width: Integer;
Size: Integer; Color1, Color2: TColor);
begin
end;
This would allow customising the grid with different sizes and colors, and not worry about the overhead of storing a large chessboard grid bitmap and having to resize it.
However I am not sure how you could draw the grid onto a bitmap? One thought I had was that you need to loop through each alternating row of the bitmap and color it that way? I am not sure.
This involves math and calculations which I am not good with. I would appreciate if you could enlighten me on the most effective way of rendering the grid on a bitmap.