![]() I'm not going to bother going over the CGdiPlusBitmap class except However, the code is so simple, it couldĮasily be modified to use CImage as the base class.) The ATL class CImage, it's because the code was used in a (If you're curious why I didn't simply derive from ![]() Suppose that if I ever had the patience and desire, I could extend that class,īut I have no need to do so. I created two classes, with the base class being a very simple encapsulation ofīitmap and the derived class encapsulating the global memory. Gdiplus::GdiplusShutdown(m_gdiplusToken) The Class The following data member to the class derived from CWinApp: GDI+ needs to be initialized before any GDI+ calls are made. Generalization, though I don't know if this is standard behavior or just aįluke with my file set.) GDI+ Initialization (My testing found that PNG and BMP files don't seem to follow this This same restriction applies to CGdiPlusBitmapResource. In other words, if you open aīitmap using Bitmap::FromFile, you cannot delete or otherwiseĬhange that file while the image is open. Information must be available at all times. With JPG, some TIFF and other formats, the original image The Gotchaīefore discussing the code itself, there is a caveat with GDI+ that must beĪddressed. Were two classes: CGdiPlusBitmap and CGdiPlusBitmapResource. ![]() After a night of rest, I decided toĮncapsulate the code in a simple class to ensure memory got freed. Perusing the Bitmap methods available, I ran across Bitmap::FromStream.Īfter a bit of testing and several errors, due mostly to the horrible GDI+ĭocumentation, I came up with working code. Like, I'm sure, other developers facing this issue, I disbelieved theĭocumentation and tried Bitmap::FromResource to no avail. Quickly found GDI+ to be poorly designed and very quirky, but it worked wellįor my purposes until I discovered, to my horror, that GDI+ cannot load JPG or LeadTools and the open source libraries for both formats, but wanted myĮxecutable to be as small as possible. Recently, I needed to display some JPG and PNG files.
0 Comments
Leave a Reply. |