Bitmap.Scanline lazarus / 39-Graphics ---------------------------------------------------------------------- mbdev · 2013-05-05 12:23 Hello, Could you help me translate this lines from Delphi to Lazarus? Code: [Select] Bitmap.Width := FWidth;  Bitmap.Height := FHeight;  Bitmap.PixelFormat := pf32bit;  CopyMemory(Bitmap.Scanline[Bitmap.Height - 1], @FBitmap[0], FWidth * FHeight * SizeOf(TRGBQUAD)); ---------------------------------------------------------------------- exdatis · 2013-05-05 13:34 For a full functionality you can try BGRA controls, BGRABitmap: http://wiki.freepascal.org/BGRAControls Regards p.s. I'm not sure but I think Image32 also... ---------------------------------------------------------------------- User137 · 2013-05-05 14:35 You can do that through RawImage aswell, if you don't want to rely on 3rd party libraries. Code: [Select]TRGBQUAD = record     rgbBlue : BYTE;     rgbGreen : BYTE;     rgbRed : BYTE;     rgbReserved : BYTE;   end; var   Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject); var b1, b2: TBitmap; data1, data2: PByte; begin   b1:=TBitmap.Create;   b2:=TBitmap.Create;   b1.PixelFormat:=pf32bit;   b2.PixelFormat:=pf32bit;   b1.SetSize(100, 100);   b2.SetSize(100, 100);   b1.Canvas.Font.Color:=clRed;   b1.Canvas.TextOut(10, 10, 'Test');   data1:=b1.RawImage.Data;   data2:=b2.RawImage.Data;   move(data1^, data2^,     b1.Width * b1.Height * SizeOf(TRGBQUAD));     // This here would be perfect but it doesn't compile..   // so i had to pass them through data1, data2 variables instead.   //move(b1.RawImage.Data^, b2.RawImage.Data^,   //  b1.Width * b1.Height * SizeOf(TRGBQUAD));   b1.Free;   b2.SaveToFile('c:\test.bmp');   b2.Free; end;This code here made me a test.bmp with red 'Test' written in it. ---------------------------------------------------------------------- mica · 2013-05-05 16:30 graphic32 can help to http://graphics32.org/documentation/Docs/Units/GR32/Classes/TCustomBit map32/Properties/ScanLine.htm ---------------------------------------------------------------------- mbdev · 2013-05-06 13:56 Hi, I tried this Code: [Select][...] private .... FBitmap: array of TRGBQUAD; procedure TPathTracer.Acquire(Bitmap: TBGRABitmap); begin  Bitmap.SetSize(Fwidth,fheight);  CopyMemory(Bitmap.ScanLine[Bitmap.Height - 1], @FBitmap[0], FWidth * FHeight * SizeOf(TRGBQUAD)); end;  but I wouldn't do the same :/ Moreover I didn't found Scanline in the TCustomBitmap32. ---------------------------------------------------------------------- exdatis · 2013-05-06 15:00 http://wiki.freepascal.org/BGRABitmap_tutorial_4 ---------------------------------------------------------------------- circular · 2013-05-07 12:11 @mbdev: If you want to copy all data, you must use the Data property. If you use Scanline, you must copy each line separately. This is because the line order is not the same depending on the operating system. If you want to copy all Data at once, and that you need to have lines in a specific order, you can check the LineOrder property, and apply VerticalSwap if needed. ---------------------------------------------------------------------- User137 · 2013-05-07 15:32 Is that somehow different using TBitmap.RawImage.Data or TBGRABitmap.Data? ---------------------------------------------------------------------- circular · 2013-05-18 15:17 It can be because TBGRABitmap.Data is always 32-bit BGRA, hence the name of the library. Whereas with a TBitmap, the format can change depending on the image or on the operating system.