How to use ScanLine (Views: 30)
Problem/Question/Abstract: Can someone explain to me how to use the ScanLine function? I tried the example in the Help, only got a black box. Answer: type PRGBs = ^TRGBs; TRGBs = array[0..1000000] of TRGBTriple; var r, g, b: Byte2DArray; {customer implemented} procedure VirtualImageRGB.fromimage(t: TImage); var x, y: Integer; P: PRGBs; begin for y := 0 to t.picture.Bitmap.Height - 1 do begin P := PRGBs(t.picture.Bitmap.Scanline[y]); for x := 0 to t.picture.Bitmap.Width - 1 do with P^[x] do begin r[x, y] := rgbtRed; g[x, y] := rgbtGreen; b[x, y] := rgbtBlue; end; end; end; procedure VirtualImageRGB.toimage(t: TImage); var x, y: Integer; P: PRGBs; begin for y := 0 to t.picture.Bitmap.Height - 1 do begin P := PRGBs(t.picture.Bitmap.Scanline[y]); for x := 0 to t.picture.Bitmap.Width - 1 do with P^[x] do begin rgbtRed := r[x, y]; rgbtGreen := g[x, y]; rgbtBlue := b[x, y]; end; end; t.canvas.draw(0, 0, t.picture.Bitmap); end; |