c++ - How can I load an image from a resource using GDI+? -
I try to load a non-bmp image (png in my case) with a resource in a bitmap / image example My app is because the bitmap constructor has a surcharge for only a bitmap resource, so that's what I've come across:
I allocate memory on a global heap, and then in it Copy the resource data. Then I am making an Istem for the global memory block (using CreateStreamOnHGlobal) and use the image / bitmap constructor which takes that stream. Actually this works, though I'm not sure it's the best way to do this: I've found that if I clear the memory block after creating the image, it will not be dragged (Drying Calling Anything Will not). Which raises two questions:
-
How can I manage the life of that memory block? I suspect it will be given on the destruction of the image.
-
Does the picture / bitmap class use PGN data in compressed form and translate it into raw data of the drymage on each call? It seems very unforgivable.
Any sugestions?
While using non-bitmap resources I have based my code on it.
ishma * pStream = NULL; :: CreateStreamOnHGlobal (m_hBuffer, FALSE, and pStream) m_p bitmap = Gdiplus :: bitmap :: sstream (pStream); Pstream- & gt; Release (); When you see that code from the stream to create a bitmap, you can call release () on the stream to remove your reference number on the stream Which makes the life of the stream bound in bitmap.
You can then use the pointer that wants to manage the pointer.
Comments
Post a Comment