Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi HBITMAP ---> TBitmap? (https://www.delphipraxis.net/49185-hbitmap-tbitmap.html)

TheXception 6. Jul 2005 19:01


HBITMAP ---> TBitmap?
 
Wie kann ich aus HBITMAP ein TBitmap machen?

SirThornberry 6. Jul 2005 19:19

Re: HBITMAP ---> TBitmap?
 
in dem du ein TBitmap creirst und das Handle zuweist
Delphi-Quellcode:
var LBitmap: TBitmap;
begin
  LBitmap := TBitmap.Create;
  LBitmap.Handle := YourHBitmap;
  //do anything with LBitmap
  LBitmap.Free;

turboPASCAL 6. Jul 2005 19:21

Re: HBITMAP ---> TBitmap?
 
Zitat:

Zitat von Die Hilfe (F1)
...Der Wert der Eigenschaft Handle bezeichnet die HBITMAP-Struktur, das vom Bitmap-Objekt gekapselt wird. Ein direkter Zugriff auf das Handle sollte vermieden werden, weil das HBITMAP-Objekt sonst kopiert wird, falls das Handle von mehreren TBitmap-Objekten verwendet wird. ...

-> HBITMAP = TBitmap

Delphi-Quellcode:
procedure FormX.DiesUndDas...

var TheBitmap: TBitmap { => HBITMAP }
begin
  TheBitmap.Width := 320;
  TheBitmap.Height := 240;
  TheBitmap.PixelFormat := pf24Bit;

  // in das Bitmap Zeichnen
  TheBitmap.Canvas.Rectangle(10, 10, 20,20);
  ...
  ...
end;

TheXception 6. Jul 2005 19:24

Re: HBITMAP ---> TBitmap?
 
Danke werd ich glei mal ausprobieren

SirThornberry 6. Jul 2005 19:26

Re: HBITMAP ---> TBitmap?
 
@turboPASCAL: HBitmap ist nicht gleich TBitmap. HBitmap ist einfach ein HandleTyp der eben für das WindowsBitmap steht. Wäre HBitmap = TBitmap dann wäre TBitmap ja rekursiv verschaltet, denn TBitmap hat das Property Handle was vom Typ HBitmap ist. Und wenn das nur ein TBitmap wäre, könnte man es ja zu TBitmap casten und dann wieder auf Handle zugreifen und so weiter.

turboPASCAL 6. Jul 2005 19:35

Re: HBITMAP ---> TBitmap?
 
@SirThornberry
So war es auch nicht gemeint, etwas blöde Darstellung, sorry.

SirThornberry 6. Jul 2005 19:37

Re: HBITMAP ---> TBitmap?
 
@turboPASCAL: ok, dann hab ich's falsch verstanden...

Olli 6. Jul 2005 19:43

Re: HBITMAP ---> TBitmap?
 
Bei TBitmap kommt es immer darauf an in welchem Scope du es betrachtest. Wenn du also den Scope-Operator nimmst und Windows.TBitmap angibst, ist das kein Objekt mehr, sondern ein record:
Delphi-Quellcode:
{ Bitmap Header Definition }
  PBitmap = ^TBitmap;
  {$EXTERNALSYM tagBITMAP}
  tagBITMAP = packed record
    bmType: Longint;
    bmWidth: Longint;
    bmHeight: Longint;
    bmWidthBytes: Longint;
    bmPlanes: Word;
    bmBitsPixel: Word;
    bmBits: Pointer;
  end;
  TBitmap = tagBITMAP;
  {$EXTERNALSYM BITMAP}
  BITMAP = tagBITMAP;
Ein Record ist zwar kein Handle, aber es ist auch keine Klasse ;)

Von was sprechen wir hier also, wenn wir von TBitmap sprechen?


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:47 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