none
How to Load Images (bmp, jpeg, gif, tiff)

Answers

  • You could use the Image class of GDI+.
    This loads files of type BMP, ICON, GIF, JPEG, Exif, PNG, TIFF, WMF, and EMF.

    «_Superman_»
    Friday, March 13, 2009 8:16 AM
  • #include <windows.h> 
     
    // Gdiplus 
    #pragma comment( lib, "gdiplus.lib" ) 
    #include <gdiplus.h> 
     
    static const wchar_t* filename= L"C:\\WINDOWS\\Web\\Wallpaper\\Autumn.jpg"
     
    int main( void ) 
        // Start Gdiplus 
        Gdiplus::GdiplusStartupInput gdiplusStartupInput; 
        ULONG_PTR gdiplusToken; 
        Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); 
     
        // Load the image 
        Gdiplus::Image* image = Gdiplus::Image::FromFile( filename ); 
     
        // do something with your image 
        // ... 
     
        // delete the image when done 
        delete image; image = 0; 
     
        // Shutdown Gdiplus 
        Gdiplus::GdiplusShutdown(gdiplusToken); 
     
    Tuesday, March 17, 2009 1:32 PM

All replies

  • You could use the Image class of GDI+.
    This loads files of type BMP, ICON, GIF, JPEG, Exif, PNG, TIFF, WMF, and EMF.

    «_Superman_»
    Friday, March 13, 2009 8:16 AM
  • Not sure what you mean "all file types". You can invent your own way to store image. Before you release the format specification, there won't be a public function that works with your file type. 

    The C++ language does not support any image format. You need to find an image processing library for that. If you are targeting Windows versions higher than Windows NT 4.0 SP6 or Windows 98, you can use GDI+ to read a limited set of image formats. If you have questions about Windows's image support, search or ask in one of the  Software Development for Windows Client forums.

    MSMVP VC++
    Friday, March 13, 2009 4:59 PM
  • #include <windows.h> 
     
    // Gdiplus 
    #pragma comment( lib, "gdiplus.lib" ) 
    #include <gdiplus.h> 
     
    static const wchar_t* filename= L"C:\\WINDOWS\\Web\\Wallpaper\\Autumn.jpg"
     
    int main( void ) 
        // Start Gdiplus 
        Gdiplus::GdiplusStartupInput gdiplusStartupInput; 
        ULONG_PTR gdiplusToken; 
        Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); 
     
        // Load the image 
        Gdiplus::Image* image = Gdiplus::Image::FromFile( filename ); 
     
        // do something with your image 
        // ... 
     
        // delete the image when done 
        delete image; image = 0; 
     
        // Shutdown Gdiplus 
        Gdiplus::GdiplusShutdown(gdiplusToken); 
     
    Tuesday, March 17, 2009 1:32 PM