I want 2 Image (Image1, Image2) of TImage type, one (Image2, foreground) overlaying the other (Image1, background).
The Image1 must contain a Jpeg image, the Image2 must be a transparent (on clBlack color) bitmap over the user can draw lines.
I have write the following code, but this not work, what I obtain is a black image over a background image, but where the white line I draw is transparent!
Instead what I want is a white line over background image.
Can you help me?
Thanks
source code:
unit Unit1;
{$I ImagingOptions.inc}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls,
ImagingTypes,
Imaging,
ImagingClasses,
ImagingComponents,
ImagingCanvases,
ImagingUtility;
type
{ TForm1 }
TForm1 = class(TForm)
Image1: TImage;
Image2: TImage;
private
{ private declarations }
public
{ public declarations }
FBitmap1: TImagingBitmap;
FImage1: TMultiImage;
FBitmap2: TImagingBitmap;
FImage2: TMultiImage;
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
FImage1 := TMultiImage.Create;
FBitmap1 := TImagingBitmap.Create;
Image1.Picture.Graphic := FBitmap1;
FImage1.LoadMultiFromFile('e:\background.jpg'); // my background image
Image1.Picture.Graphic.Assign(FImage1);
FImage2 := TMultiImage.Create;
FBitmap2 := TImagingBitmap.Create;
Image2.Picture.Graphic := FBitmap2;
FImage2.LoadMultiFromFile('e:\foreground.bmp'); // my foreground image, a black bitmap of same dimension of background image
Image2.Picture.Graphic.Assign(FImage2);
Image2.Picture.Bitmap.Transparent := True;
Image2.Picture.Bitmap.TransparentColor := clBlack;
Image2.Canvas.Pen.Color := clWhite;
Image2.Canvas.Line(0, 0, 200, 200);
end;
initialization
{$I Unit1.lrs}
end.