On 2011-04-19 10:39:59 -0300, Leonardo M. Ramé wrote:
> Hi, I'm working with a library that let me get a pointer to an UInt8
> array containing the pixels of an image.
> To show the image on screen, using Lazarus, I must know the
> Red,Green,Blue and Alpha values of each pixel (am I right?), how can I
> convert each byte of the UInt8 array to RGBA?
> Thanks in advance,
Let me answer to myself.
I didn't know that I can use lBuffer as an array, so, the index 0 ->
Red, 1 -> Green, 2 -> Blue, 3 -> Alpha.
Here's how a buffer can be paint on a form using TBGRABitmap:
lBmp := TBGRABitmap.Create(FImgWidth, FImgHeight);
for y := 0 to lBmp.Height-1 do
p := lBmp.Scanline[y];
for x := 0 to lBmp.Width-1 do
p^.red := lBuffer;
p^.green := lBuffer;
p^.blue := lBuffer;
p^.alpha := lBuffer;
// Self is a TForm
lBmp.Draw(Self.Canvas, 0, 0);