Posts: 110
Threads: 30
Joined: Dec 2019
Reputation:
0
Location: Россия
Delphi has a TImage component. I use it like this:
...
mPng.LoadFromStream(mStream2);
Image1.Canvas.Draw(0,0,mPng);
...
IntraWeb has a TIWimage component, but it does not have a Canvas property. How to use it?
Posts: 2,078
Threads: 167
Joined: Mar 2018
Reputation:
69
Location: Auckland, New Zealand
You are correct, there is no canvas in TIWImage.
If you need to draw directly to a canvas, you need fist to create a TBitmap instance, draw into the bitmap canvas and then assign the Bitmap to the TIWImage.Picture property.
Posts: 110
Threads: 30
Joined: Dec 2019
Reputation:
0
Location: Россия
05-27-2022, 04:29 AM
(This post was last modified: 05-27-2022, 08:36 AM by Сергей Александрович.)
The drawing is not displayed. Can you tell me what the problem is?
procedure TfmShowQRC.IWAppFormShow(Sender: TObject);
var
mStream1 : TMemoryStream;
mStream2 : TMemoryStream;
mPng : TPngobject;
mPicture : TPicture;
mBmp : TBitMap;
begin
mStream1 := TMemoryStream.Create;
mStream2 := TMemoryStream.Create;
mPng := TPNGObject.Create;
mBmp := TBitmap.Create;
try
mQRC := TestPictureBase64;
mStream1.WriteBuffer(mQRC[1],Length(mQRC)*SizeOf(Char));
mStream1.Position:=0;
DecodeStream(mStream1,mStream2);
mStream2.Position := 0;
mPng.LoadFromStream(mStream2);
mBmp.Canvas.Draw(0,0,mPng);
IWImage.Picture.Bitmap := mBmp;
finally
FreeAndNil(mStream1);
FreeAndNil(mStream2);
FreeAndNil(mPng);
FreeAndNil(mBmp);
end;
end;
And here is a working code for VCL:
procedure TfmViewQRC.FormShow(Sender: TObject);
var
mStream1 : TMemoryStream;
mStream2 : TMemoryStream;
mPng : TPngobject;
mBmp : TBitmap;
begin
mContent := TestPictureBase64;
mStream1 := TMemoryStream.Create;
mStream2 := TMemoryStream.Create;
mPng := TPNGObject.Create;
try
mStream1.WriteBuffer(mContent[1],Length(mContent)*SizeOf(Char));
mStream1.Position:=0;
DecodeStream(mStream1,mStream2);
mStream2.Position := 0;
mPng.LoadFromStream(mStream2);
Image1.Canvas.Draw(0,0,mPng);
finally
mStream1.Destroy;
mStream2.Destroy;
mPng.Destroy;
end;
end;