AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi Cannot Assign TBitmapCanvas to TBitmapCanvas
Thema durchsuchen
Ansicht
Themen-Optionen

Cannot Assign TBitmapCanvas to TBitmapCanvas

Ein Thema von sk.Silvia · begonnen am 26. Feb 2006 · letzter Beitrag vom 27. Feb 2006
Antwort Antwort
Benutzerbild von sk.Silvia
sk.Silvia

Registriert seit: 8. Feb 2006
Ort: Slovenia
90 Beiträge
 
Delphi 7 Personal
 
#1

Cannot Assign TBitmapCanvas to TBitmapCanvas

  Alt 26. Feb 2006, 18:45
hi alle

ich hab probleme mit diesen part fo code

Delphi-Quellcode:
  
  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;
it creates a runtime error "Cannot Assign TBitmapCanvas to TBitmapCanvas" what is nonesence..isnt it??
i just only want to save the canvas into TBitmap (and dont want to make it over Pixels[], cuz its too slow)
  Mit Zitat antworten Zitat
Dust Signs

Registriert seit: 28. Dez 2004
Ort: Salzburg
379 Beiträge
 
#2

Re: Cannot Assign TBitmapCanvas to TBitmapCanvas

  Alt 26. Feb 2006, 18:49
You could use CopyRect or BitBlt instead. And don't forget to free the tmp bitmap

Dust Signs
(aka AXMD in der EE)
Die Nummer, die Sie gewählt haben, ist imaginär. Bitte drehen Sie Ihr Telefon um 90° und versuchen Sie es erneut.
  Mit Zitat antworten Zitat
Benutzerbild von sk.Silvia
sk.Silvia

Registriert seit: 8. Feb 2006
Ort: Slovenia
90 Beiträge
 
Delphi 7 Personal
 
#3

Re: Cannot Assign TBitmapCanvas to TBitmapCanvas

  Alt 26. Feb 2006, 19:29
ok i used

ShowScr.Canvas.CopyRect(ShowScr.Canvas.ClipRect,Screen.Canvas,Screen.ClientRect); thats fine, but only in the case that ShowScr is the same size (width, height) as Screen, when not i get enlarged picture
  Mit Zitat antworten Zitat
Dust Signs

Registriert seit: 28. Dez 2004
Ort: Salzburg
379 Beiträge
 
#4

Re: Cannot Assign TBitmapCanvas to TBitmapCanvas

  Alt 26. Feb 2006, 19:33
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
(aka AXMD in der EE)
Die Nummer, die Sie gewählt haben, ist imaginär. Bitte drehen Sie Ihr Telefon um 90° und versuchen Sie es erneut.
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#5

Re: Cannot Assign TBitmapCanvas to TBitmapCanvas

  Alt 26. Feb 2006, 19:47
Hi Silvia,

Zitat von sk.Silvia:
i just only want to save the canvas into TBitmap
you can do that and more when you pick up GrabImage() over there: klick

Delphi-Quellcode:
procedure TDemoForm.GrabButtonClick(Sender: TObject);
begin
  with GrabImage(GetDesktopWindow) do
  begin
    if SaveDialog.Execute then
      SaveToFile(SaveDialog.FileName);
    Free;
  end;
end;
Kind regards

marabu
  Mit Zitat antworten Zitat
Benutzerbild von sk.Silvia
sk.Silvia

Registriert seit: 8. Feb 2006
Ort: Slovenia
90 Beiträge
 
Delphi 7 Personal
 
#6

Re: Cannot Assign TBitmapCanvas to TBitmapCanvas

  Alt 26. Feb 2006, 19:58
i know, but its doing the same with ClinetRect, i try to do the following

http://www.politea.sk/mpp01.jpg

the screen canvas i only work woth (isnt displayed) and diplayed is only ShowScr which contains a part of Screen.Canvas
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#7

Re: Cannot Assign TBitmapCanvas to TBitmapCanvas

  Alt 26. Feb 2006, 20:50
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:
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;
marabu
  Mit Zitat antworten Zitat
Benutzerbild von sk.Silvia
sk.Silvia

Registriert seit: 8. Feb 2006
Ort: Slovenia
90 Beiträge
 
Delphi 7 Personal
 
#8

Re: Cannot Assign TBitmapCanvas to TBitmapCanvas

  Alt 27. Feb 2006, 19:24
thank you
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:10 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz