Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my project I want to load a jpg image from file, but the result always is 0x0000000. i have tried more than more. if anyone knows what is the problem please tell me.

i have used:
#include <string>
#include <gdiplus.h>
#include <iostream>

using namespace std;
using namespace Gdiplus;

#pragma comment(lib,"GdiPlus.lib")

and my code is :
    wifstream infile("jpgfiles.txt")
while(!infile.eof()){

    WCHAR _file[MAX_PATH];

    infile.getline(_file,MAX_PATH,'\n');


    Bitmap* gpBitmap = new Bitmap(_file);
            int e = GetLastError();
            char num1[10];
            itoa(e,num1,10);
            MessageBoxA(0,num1,"error",MB_OK);
    }


the messagebox always prints 0 and gpBitmap is 0x00000000.
thank you.
Posted
Updated 30-Oct-13 10:21am
v3

1 solution

Possibly you forgot to call the GdiplusStartup function, as the documentation ("GdiplusStartup function" at MSDN[^]) states:
You must call GdiplusStartup before you create any GDI+ objects, and you must delete all of your GDI+ objects (or have them go out of scope) before you call GdiplusShutdown.
 
Share this answer
 
Comments
xLordProgrammer 31-Oct-13 1:35am    
thank you so much for your nice solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900