![]() |
| | #1 |
| Not stupid, just stupider Join Date: May 2007 Location: Earthland
Posts: 182
| I have looked at libpng.org: top level, but that seems to only do PNG files and I'm not sure if it can turn it into a HBITMAP. Anyone know anything about this? Thanks. |
| yaya is offline | |
| | #2 |
| train spotter Join Date: Aug 2001 Location: near a computer
Posts: 3,451
| Have you looked at GDI+ (GDIPlus)? MFC CImage or .NET C# Graphics objects will handle most formats, inc. jpg and pgn (IIRC).
__________________ "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter." Friedrich Nietzsche "I spent a lot of my money on booze, birds and fast cars......the rest I squandered." George Best "If you are going through hell....keep going." Winston Churchill |
| novacain is offline | |
| | #3 |
| Not stupid, just stupider Join Date: May 2007 Location: Earthland
Posts: 182
| Sorry, I forgot to mention, I'm just using C/C++ Win32, no MFC. I haven't done much in the way of the GDI... so this can do it without too much trouble? |
| yaya is offline | |
| | #4 |
| train spotter Join Date: Aug 2001 Location: near a computer
Posts: 3,451
| GDI won't work without a 3rd party library (need GDI+ or .NET). You didn't mention your IDE/complier. In MSVC you could write a MFC dll to convert the images and call it from your WIN32 app. This dll would be very simple, follow the MFC wiz and create a DLL (static link the MFC libs), then export the following function to get the HBITMAP. Code: #include <atlimage.h> // CImage
#define DLLExport __declspec (dllexport) //dllimport in app
//error checking required
DLLExport HBITMAP ConvertImage(char *szFullpath)
{
CString sFullpath(szFullpath);
CImage Image;
Image.Load(sFullpath);
return Image.Detach();
}
__________________ "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter." Friedrich Nietzsche "I spent a lot of my money on booze, birds and fast cars......the rest I squandered." George Best "If you are going through hell....keep going." Winston Churchill |
| novacain is offline | |
| | #5 |
| Not stupid, just stupider Join Date: May 2007 Location: Earthland
Posts: 182
| Ah, I see. I'll look into this and give it a go soon. Thanks. |
| yaya is offline | |
| | #6 |
| Malum in se Join Date: Apr 2007
Posts: 3,188
| You can also use something like cximage, and convert the image in memory to a bmp which you then blit into the HBITMAP.
__________________ Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off. |
| abachler is offline | |
| | #7 |
| Registered User Join Date: Apr 2007
Posts: 136
| You don't need any external library (never on Windows) GDI+ manages all imaginable formats. JPEG and others are also native with COM or Shell apis. |
| Alex31 is offline | |
| | #8 | |
| train spotter Join Date: Aug 2001 Location: near a computer
Posts: 3,451
| Quote:
You may have also noticed that GDI (without the '+') will only handle BMPs (and so WILL require a 3rd party lib). Please try to keep up....
__________________ "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter." Friedrich Nietzsche "I spent a lot of my money on booze, birds and fast cars......the rest I squandered." George Best "If you are going through hell....keep going." Winston Churchill | |
| novacain is offline | |
| | #9 |
| Algorithm Dissector Join Date: Dec 2005 Location: New Zealand
Posts: 2,741
| I recommend using OleLoadPicture on Windows. Here's some sample code that uses it. CodeProject: Rendering GIF, JPEG, Icon, or Bitmap Files with OleLoadPicture. Free source code and programming help
__________________ My homepage Advice: Take only as directed - If symptoms persist, please see your debugger |
| iMalc is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| placing two bmp images side by side | nina_code | C++ Programming | 2 | 07-14-2009 11:10 AM |
| Loading Images in C | bucyyohare | C Programming | 5 | 02-28-2008 05:52 PM |
| BMP Loading Structs | IdioticCreation | C++ Programming | 4 | 07-05-2007 12:42 PM |
| how come... (bmp loading) | Homunculus | Windows Programming | 4 | 03-21-2006 09:00 PM |
| Loading .jpg images from a file | Echidna | Windows Programming | 4 | 04-20-2002 03:09 PM |