![]() |
Cannot Assign TBitmapCanvas to TBitmapCanvas
hi alle:)
ich hab probleme mit diesen part fo code
Delphi-Quellcode:
it creates a runtime error "Cannot Assign TBitmapCanvas to TBitmapCanvas" what is nonesence..isnt it??procedure TEngine.Show; var tmp:TBitmap; begin tmp:=TBitmap.Create; tmp.Canvas.Assign(Screen.Canvas); ShowScr.Canvas.Draw(-10,-10,tmp); ShowScr.Canvas.LineTo(50,50); end; i just only want to save the canvas into TBitmap (and dont want to make it over Pixels[], cuz its too slow) |
Re: Cannot Assign TBitmapCanvas to TBitmapCanvas
You could use CopyRect or BitBlt instead. And don't forget to free the tmp bitmap ;)
Dust Signs |
Re: Cannot Assign TBitmapCanvas to TBitmapCanvas
ok i used
Delphi-Quellcode:
thats fine, but only in the case that ShowScr is the same size (width, height) as Screen, when not i get enlarged picture:(
ShowScr.Canvas.CopyRect(ShowScr.Canvas.ClipRect,Screen.Canvas,Screen.ClientRect);
|
Re: Cannot Assign TBitmapCanvas to TBitmapCanvas
Well, why do you work with the ShowScr's cliprect then? Your method only works if the two cliprects are exactly equal (if you don't want to have anything enlarged ;))
Dust Signs |
Re: Cannot Assign TBitmapCanvas to TBitmapCanvas
Hi Silvia,
Zitat:
![]()
Delphi-Quellcode:
Kind regards
procedure TDemoForm.GrabButtonClick(Sender: TObject);
begin with GrabImage(GetDesktopWindow) do begin if SaveDialog.Execute then SaveToFile(SaveDialog.FileName); Free; end; end; marabu |
Re: Cannot Assign TBitmapCanvas to TBitmapCanvas
i know, but its doing the same with ClinetRect, i try to do the following
![]() the screen canvas i only work woth (isnt displayed) and diplayed is only ShowScr which contains a part of Screen.Canvas |
Re: Cannot Assign TBitmapCanvas to TBitmapCanvas
Your choice of variable names confused me. Screen is a well known VCL management object and has no canvas property. It seems you have two bitmaps - one to hold a full image and one to hold an arbitrary rect cut out of the full image. CopyRect would be my choice to accomplish this. The code for ClipButtonClick is my test code:
Delphi-Quellcode:
marabu
procedure GetViewPort(bmFull, bmPart: TBitmap; TopLeft: TPoint);
var r: TRect; begin with bmPart do r := Bounds(TopLeft.X, TopLeft.Y, Width, Height); with bmPart.Canvas do CopyRect(ClipRect, bmFull.Canvas, r); end; procedure TDemoForm.ClipButtonClick(Sender: TObject); var bmFull: TBitMap; begin bmFull := GrabImage(GetDesktopWindow); with Image.Picture.Bitmap do begin Width := Image.Width; Height := Image.Height; end; GetViewPort(bmFull, Image.Picture.Bitmap, Point(100, 100)); bmFull.Free; end; |
Re: Cannot Assign TBitmapCanvas to TBitmapCanvas
thank you :hello: :spin: :kiss:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:08 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz