Board index » delphi » TBitmap.Handle

TBitmap.Handle

Is it normal that assigning Bitmap to Image changes handle of that bitmap ??
I.e.
  h1 := bmp.Handle;
  Image1.Picture.Assign(bmp);
  h2 := bmp.Handle;

Now h1 <> h2 !

--
Ivan

 

Re:TBitmap.Handle


Quote
"Ivan Prenosil" <preno...@ms.anet.cz> wrote in message

news:3c07857e$1_2@dnews...
Quote
> Is it normal that assigning Bitmap to Image changes handle of that bitmap
??
> I.e.
>   h1 := bmp.Handle;
>   Image1.Picture.Assign(bmp);
>   h2 := bmp.Handle;

> Now h1 <> h2 !

When Assigning to Picture Property, TImage make a Copy of the Bitmap.
the Original Bitmap never go into the TImage.

Re:TBitmap.Handle


Quote
> >   h1 := bmp.Handle;
> >   Image1.Picture.Assign(bmp);
> >   h2 := bmp.Handle;

> > Now h1 <> h2 !

> When Assigning to Picture Property, TImage make a Copy of the Bitmap.
> the Original Bitmap never go into the TImage.

Yes, but it is Original Bitmap's handle that is changing.

--
Ivan

Re:TBitmap.Handle


Quote
"Ivan Prenosil" <preno...@ms.anet.cz> wrote in message

news:3c07ae65_1@dnews...

Quote
> > >   h1 := bmp.Handle;
> > >   Image1.Picture.Assign(bmp);
> > >   h2 := bmp.Handle;

> > > Now h1 <> h2 !

> > When Assigning to Picture Property, TImage make a Copy of the Bitmap.
> > the Original Bitmap never go into the TImage.

> Yes, but it is Original Bitmap's handle that is changing.

Strictly Speaking, When Assigning  a TBitmap to another TBitmap,
TBitmaps share the same bitmap until TBitmap tries to change it.
When TBitmap tries to change, TBitmap make a Copy of Bitmap.
This 'Copy On Write Algorithm' make things slightly complicate.

Other Threads