hi
how to convert this code to lazarus.
procedure FindAlphaChannel(Dest, Image0, Image1: TBitmap; Bk1, Bk2: Cardinal);
var
Index : Integer;
ScanIndx: Integer;
BackValue1: Real;
BackValue2: Real;
Pixel1: Real;
Pixel2: Real;
Pixel : Real;
Alpha : Real;
Read0: PCardinal;
Read1: PCardinal;
Write: PCardinal;
Color: Cardinal;
begin
BackValue1:= Pixel2GrayEx(Bk1);
BackValue2:= Pixel2GrayEx(Bk2);
if (Image0.PixelFormat <> pf32bit) then Image0.PixelFormat:= pf32bit;
if (Image1.PixelFormat <> pf32bit) then Image1.PixelFormat:= pf32bit;
Dest.Width := Image0.Width;
Dest.Height:= Image0.Height;
if (Dest.PixelFormat <> pf32bit) then Dest.PixelFormat:= pf32bit;
for ScanIndx:= 0 to Dest.Height - 1 do
begin
Read0:= Image0.Scanline[ScanIndx];
Read1:= Image1.Scanline[ScanIndx];
Write:= Dest.Scanline[ScanIndx];
for Index:= 0 to Dest.Width - 1 do
begin
// retreive source grayscale pixels
Pixel1:= Pixel2GrayEx(Read0^);
Pixel2:= Pixel2GrayEx(Read1^);
// calculate alpha-value and original pixel
ExtractAlpha(Pixel1, Pixel2, BackValue1, BackValue2, Alpha, Pixel);
// convert normalized pixel to color index
Color:= Round(Pixel * 255.0);
// prepare a 24-bit RGB color
Color:= Color or (Color shl 8) or (Color shl 16);
// add alpha-channel to 24-bit RGB color and write it to destination
Write^:= Color or (Round(Alpha * 255.0) shl 24);
// move through pixels
Inc(Read0);
Inc(Read1);
Inc(Write);
end;
end;
end;
thanks