procedure TForm1.Button1Click(Sender: TObject);var IntfImg1, IntfImg2: TLazIntfImage; px, py: Integer; Row1, Row2: PRGBTripleArray; abitmap:TBitmap;begin abitmap:=TBitmap.Create; abitmap.LoadFromFile('bb.bmp'); IntfImg1:=abitmap.CreateIntfImage; IntfImg2:=TLazIntfImage.Create(0,0); IntfImg2.LoadFromBitmap(aBitmap.Handle,aBitmap.MaskHandle); for py:=0 to IntfImg1.Height-1 do begin Row1 := IntfImg1.GetDataLineStart(py); //like Delphi TBitMap.ScanLine Row2 := IntfImg2.GetDataLineStart(py); //like Delphi TBitMap.ScanLine for px:=0 to IntfImg1.Width-1 do begin Row2^[px].rgbtRed := round((Row1^[px].rgbtRed+Row1^[px].rgbtGreen+Row1^[px].rgbtBlue)/3); Row2^[px].rgbtGreen := round((Row1^[px].rgbtRed+Row1^[px].rgbtGreen+Row1^[px].rgbtBlue)/3); Row2^[px].rgbtBlue := round((Row1^[px].rgbtRed+Row1^[px].rgbtGreen+Row1^[px].rgbtBlue)/3); end; end; Image1.Stretch:=True; Image1.Picture.Bitmap.LoadFromIntfImage(IntfImg2);end;
procedure TForm1.Button2Click(Sender: TObject); var IntfImg1, IntfImg2: TLazIntfImage; px, py: Integer; Row1, Row2: PRGBTripleArray; abitmap:TBitmap; CurColor: TFPColor;begin abitmap:=TBitmap.Create; abitmap.LoadFromFile('bb.bmp'); IntfImg1:=abitmap.CreateIntfImage; IntfImg2:=TLazIntfImage.Create(0,0); IntfImg2.LoadFromBitmap(aBitmap.Handle,aBitmap.MaskHandle); for py:=0 to IntfImg1.Height-1 do begin Row1 := IntfImg1.GetDataLineStart(py); //like Delphi TBitMap.ScanLine Row2 := IntfImg2.GetDataLineStart(py); //like Delphi TBitMap.ScanLine for px:=0 to IntfImg1.Width-1 do begin CurColor:=IntfImg1.Colors[px,py]; CurColor.red := round((CurColor.red+CurColor.green+CurColor.blue)/3); CurColor.green := round((CurColor.red+CurColor.green+CurColor.blue)/3); CurColor.blue := round((CurColor.red+CurColor.green+CurColor.blue)/3); IntfImg2.Colors[px,py]:=CurColor; end; end; Image1.Stretch:=True; Image1.Picture.Bitmap.LoadFromIntfImage(IntfImg2);end;
CurColor:=IntfImg1.Colors[px,py]; CurColor.red := round((CurColor.red+CurColor.green+CurColor.blue)/3); CurColor.green := round((CurColor.red+CurColor.green+CurColor.blue)/3); CurColor.blue := round((CurColor.red+CurColor.green+CurColor.blue)/3);
Do you see the mistake?
At least the second one makes for a nice "sepia effect"