I’d like to draw a bitmap pixel by pixel then save to disk but I can’t understand the docs available online. I know there’s a BGRABitmap class with direct pixel access but I wasn’t able to find the unit in my FPC distribution.

I used the image canvas before to draw bitmap fonts so I have this code working. Is there anyway to set a pixel using TFPImageCanvas? I also couldn’t figure out how to set the brush color (confusing reference once again). It looks like Lazarus has good classes but they’re so hard to discover and learn because the references aren’t complete and in one place.

What’s the best way to do this? Thanks.

procedure DrawBitmap;
var
image: TFPMemoryImage;
canvas: TFPImageCanvas;
writer: TFPWriterPNG;
begin
image := TFPMemoryImage.Create(100, 100);
 canvas := TFPImageCanvas.Create(image);

canvas.Clear;
canvas.Brush.FPColor := colRed;  // how do I set the color as an RGB?
canvas.Rectangle(0, 0, 1, 1); // how do I draw a single pixel?

writer := TFPWriterPNG.Create;
 image.SaveToFile('bitmap.png', writer);
end;

Regards,
Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to