TIWImage - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: TIWImage (/thread-2749.html) |
TIWImage - Сергей Александрович - 05-26-2022 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? RE: TIWImage - Alexandre Machado - 05-27-2022 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. RE: TIWImage - Сергей Александрович - 05-27-2022 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; RE: TIWImage - Alexandre Machado - 05-27-2022 I think your problem is when you (don't) assign the bitmap to the picture. The correct way to do it is via Assign() method of the picture, not setting the bitmap directly. This simple code works correctly (I'm not using your Base64 encoded image, but the concept is exactly the same): Code: procedure TIWForm1.IWAppFormShow(Sender: TObject); |