Dear Nigel,
Thanks.
I want to paste an bmp into the ROI selection region in an imageenvect, and the clblack pixels in the bmp should be transparent after being pasted into the roi region of imageenvect.
Thanks.
The following are the codes. It seems the pasted bmp is not transparent. The black pixels are still there.
procedure TplayAVI.ToolButton16Click(Sender: TObject);
var
i, j, uG: Integer;
P: PByteArray;
bggray: integer;
bmp:Tbitmap;
layerno:integer;
begin
ImageEnvect3.IEBitmap.Assign(imageenvect0.ieBitmap);
imageenvect3.Update;
IDSImageEnvect.Bitmap.Assign(imageenvect0.Bitmap);
IDSimageenvect.Update;
GrayToColor(IDSimageenvect.Bitmap); //This procedure will turn the gray image into color image.
IDSimageenvect.Proc.CopyToClipboard(iecpauto) ; //This will copy an ROI to the clipboard.
//-------create bmp and get rid of the given pixels such as clblack pixels.
bmp:=Tbitmap.Create;
bmp.Assign(clipboard);
bggray:= strtoint(backgroundgrayedit.Text) ;
for j := 0 to Bmp.Height - 1 do
begin
P := Bmp.ScanLine[j];
for i := 0 to Bmp.Width - 1 do
begin
uG := P[3 * i];
if ug< bggray then //set the pixels to be clblack.
begin
P[3 * i + 2] := 0;
P[3 * i + 1] := 0;
P[3 * i] := 0;
end;
end;
end;
Bmp.PixelFormat := pf32bit;
Bmp.TransparentColor:=clblack; //set the black pixels in bmp to be transparent
Bmp.Free;
ImageEnVect3.Proc.PasteFromClipboard(iecpSelection); //Paste the bmp file into the ROI in Imageenvect3.
imageenvect3.Update;
end;