Delphi code using ScanLine lazarus / 39-Graphics ---------------------------------------------------------------------- lainz · 2013-02-04 16:42 Hi, I have this code that works with Delphi, and it uses ScanLine that there's no available on lazarus, how I can convert it? See attached file. Code: [Select]// Dan de pixels zelf. Blijkbaar bestaat een icoon uit 4x4 tiles van       // 8x8 pixels.       for y := 0 to 31 do       begin         ScanLine := Icon.ScanLine[y];         for x := 0 to 31 do         begin           // Bereken de tile-index           t := ((y shr 1) and not 3) + x shr 3;           // Vermenigvuldig deze met 32 (32 bytes per tile) en tel er de           // byte-index binnen de tile bij op. Doordat alles zo mooi met           // machten van twee werkt kunnen we zelfs de modulo vervangen door           // 'and'.           i := (t shl 5) + ((x shr 1) and 3) + ((y and 7) shl 2);           // Lees de juiste nibble uit de tile-data           b := Banner.TileData[i];           if x and 1 = 1 then             b := b shr 4           else             b := b and $F;           // Pixel zetten           ScanLine^[x] := Palette[b];         end;       end; Thanks. ---------------------------------------------------------------------- howardpc · 2013-02-04 17:16 The wiki suggests this: "Since Lazarus has no TBitmap.ScanLines property, the best way to access the pixels of an image in a fast way for both reading and writing is by using TLazIntfImage. The TBitmap can be converted to a TLazIntfImage by using TBitmap.CreateIntfImage() and after modifying the pixels it can be converted back to a TBitmap by using TBitmap.LoadFromIntfImage(); Here's the sample on how to create TLazIntfImage from TBitmap, modify it and then go back to the TBitmap." Code: [Select]uses   ...GraphType, IntfGraphics, LCLType, LCLProc,  LCLIntf ... procedure TForm1.Button4Click(Sender: TObject); var   b: TBitmap;   t: TLazIntfImage; begin   b := TBitmap.Create;   try     b.LoadFromFile('test.bmp');     t := b.CreateIntfImage;     // Read and/or write to the pixels     t.Colors[10,20] := colGreen;     b.LoadFromIntfImage(t);   finally     t.Free;     b.Free;   end; end; ---------------------------------------------------------------------- circular · 2013-02-04 17:22 Well, you can use BGRABitmap of course. ---------------------------------------------------------------------- dcelso · 2013-02-04 17:35 uses   ...GraphType, IntfGraphics, LCLType, LCLProc,  LCLIntf ... procedure TForm1.Button4Click(Sender: TObject); var   bmp: TBitmap;   t: TLazIntfImage; begin   bmp := TBitmap.Create;   try     bmp.LoadFromFile('test.bmp');     t := b.CreateIntfImage; for y := 0 to 31 do       begin         ScanLine := t.getdatalinestart(y);         for x := 0 to 31 do         begin           // Bereken de tile-index           t := ((y shr 1) and not 3) + x shr 3;           // Vermenigvuldig deze met 32 (32 bytes per tile) en tel er de           // byte-index binnen de tile bij op. Doordat alles zo mooi met           // machten van twee werkt kunnen we zelfs de modulo vervangen door           // 'and'.           i := (t shl 5) + ((x shr 1) and 3) + ((y and 7) shl 2);           // Lees de juiste nibble uit de tile-data           b := Banner.TileData;           if x and 1 = 1 then             b := b shr 4           else             b := b and $F;           // Pixel zetten           ScanLine^ := Palette;         end;       end;     bmp.LoadFromIntfImage(t);   finally     t.Free;     bmp.Free;   end; end; ---------------------------------------------------------------------- lainz · 2013-02-04 18:44 Thanks to all, I will try the different solutions.