Re: Gdi+ Bitmap/Image Clone() function
- From: "GT" <tihenea@xxxxxxxxxxx>
- Date: Tue, 13 May 2008 14:56:28 -0400
Mark,
Here is my scenario: I want to create a bitmap object from raw memory.
Once the objec is created, I want to be able to delete the memory buffer
used to create it but, the bitmap object should stay around longer then the
memory used to create it. To achive this I do (pseudo code):
CreateStreamOnHGlobal to create an IStream around the raw bitmap buffer,
then
Bitmap bmp1(IStream created above) // create a temporary bitmap from stream
then create a new bitmap with Clone (bmp1.Clone() )
then bmp1 goes out of scope and it is deleted
then release the stream
Now I have a new bitmap object created from raw memory which does NOT
depends on the underlining memory used to create it.
George.
"Mark Salsbery [MVP]" <MarkSalsbery[MVP]@newsgroup.nospam> wrote in message
news:0FB5F0B7-8EFE-4E39-9E9C-49851F361D4A@xxxxxxxxxxxxxxxx
"GT" <tihenea@xxxxxxxxxxx> wrote in message
news:#eYtnADtIHA.4376@xxxxxxxxxxxxxxxxxxxxxxx
Mark,
Thanks. So one can use a technique were you wrap a memory buffer
containg a bitmap into an IStream, create the bitmap, clone it and then
dispose the IStream and the memory used.
I'm not sure exactly what you mean (some code/pseudocode would help) but
once you have the clone, you can free all other involved objects.
It's easy enough to test if you're worried about it :)
Cheers,
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
George.
"Mark Salsbery [MVP]" <MarkSalsbery[MVP]@newsgroup.nospam> wrote in
message news:5B1D31DD-4BAA-45BA-AC9E-7B0DF3AF6400@xxxxxxxxxxxxxxxx
"GT" <tihenea@xxxxxxxxxxx> wrote in message
news:ebdHb2JsIHA.5068@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
Does this function do a 'deep' cloning (really creating a full new
object from the original one) or it just increases a counter? Scanning
the news groups I found conflicting info. Some say that the copy is
'shallow' but all the docs from MS I found seems to indicate that Clone
does do a 'deep' copy?!
More specifically, if I create a new object using the Clone()
function and then destroy the original object including its supporting
data (delete the file or the IStream used to create it) is this new
object ok?
The clone is a new bitmap object completely separate from the original.
Mark
Thanks,
G.
.
- References:
- Gdi+ Bitmap/Image Clone() function
- From: GT
- Re: Gdi+ Bitmap/Image Clone() function
- From: Mark Salsbery [MVP]
- Re: Gdi+ Bitmap/Image Clone() function
- From: GT
- Re: Gdi+ Bitmap/Image Clone() function
- From: Mark Salsbery [MVP]
- Gdi+ Bitmap/Image Clone() function
- Prev by Date: Re: Gdi+ Bitmap/Image Clone() function
- Next by Date: MouseOver event on DrawString text?
- Previous by thread: Re: Gdi+ Bitmap/Image Clone() function
- Next by thread: Printing 32 bit DIBs with an alpha channel?
- Index(es):
Relevant Pages
|