Home » C++ ProgrammingRSS

CreateImageFromFile() not able to load other images

I am trying to load jpg images using IImageFactory, using the sample code provided under the name Imaging.

I am using Visual C++ platform.

But the problem is that i am unable to load images other than flower.jpg.

I even copied other images to the Imaging folder and tried to load them but it did not work.

i tried "\\program files\\imaging\\flower2.jpg"

When i set the path for other images again it is not able to load.

eg:"C:\\Documents and Settings\\asd\\Desktop\\paper.jpg"

code:

CoInitializeEx(NULL, COINIT_MULTITHREADED);

    // Create the imaging factory.
    if (SUCCEEDED(CoCreateInstance (CLSID_ImagingFactory,
                                    NULL,
                                    CLSCTX_INPROC_SERVER,
                                    IID_IImagingFactory,
                                    (void **)&pImgFactory)))
    {
        // Load the image from the JPG file.
        if (SUCCEEDED(pImgFactory->CreateImageFromFile(

                      // TEXT("\\program files\\imaging\\flower.jpg"),


                       TEXT("C:\\Documents and Settings\\asd\\Desktop\\paper.jpg"), &pImage)))
        {
            // Draw the image.
            pImage->Draw(hdc, &rc2, NULL);
            pImage->Release();
        }

 

Please help to solve this issue.

Thankx

 

3 Answers Found

 

Answer 1

The path  TEXT("C:\\Documents and Settings\\asd\\Desktop\\paper.jpg") is invalid if you have used on Pocket PC. What do you mean Imaging folder, is it on Pocket PC?

 

Answer 2

Smart device does not support drive letters (such as C: or D:); In addition, you cannot access files on the desktop from device directly. Please read the following FAQ:

There are no relative paths or driver letters in Windows Mobile/CE

 

Answer 3

Thanks for the reply.

I got my mistake. I was trying to access a file  that was not in the mobile emulator.

Now i am using WMDC to load  files in the emulator device and then using it in my code.

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter