Using GdPicture in MFC

Discussions about GdPicture.NET usage in non managed applications built in vb6, Delphi, vfp, MFC c++ etc...
Post Reply
Posts: 8
Joined: Thu May 16, 2013 2:46 am

Using GdPicture in MFC

Post by AllanS » Fri Oct 11, 2013 4:38 am

I am trying to use CGdPictureImaging class in MFC and having trouble
I have GdPicture.NET.9

I installed the program, then registered the dll using framework 2.0 and created the tlb.
Then I generated the CLicenseManager and CGdPictureImaging classes from the tlb.
So far so good.

Then I tried the following code:

CLicenseManager* pLicenseManager = new CLicenseManager();
CGdPictureImaging* pGdImaging = new CGdPictureImaging();
long lImageID = pGdImaging ->CreateGdPictureImageFromFile(path_of_the_photo);
long lError = pGdImaging ->GetStat();
pGdImaging ->ReleaseGdPictureImage(lImageID);

the lImageID and lError returned by both functions would be -858993460, and I'm not sure what steps I missed.
I am not sure if I actually need to instantiate a new class with GdPicture in COM, but I tried both instantiating and without.
I did realized the m_lpDispatch inside the classes are 0, but I'm not sure how to fix that.

Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Using GdPicture in MFC

Post by Cedric » Wed Oct 16, 2013 3:40 pm

Hello Allan,

The way you are creating the objects is wrong. Here is what you should be doing:

Code: Select all

CLicenseManager pLicenseManager;
pLicenseManager.RegisterKEY(L"XXXX"); // Please replace XXXX with your license key

CGdPictureImaging pGdImaging;
long lImageID = pGdImaging.CreateGdPictureImageFromFile(L"D:\test.jpg");
long lError = pGdImaging.GetStat();

Posts: 8
Joined: Thu May 16, 2013 2:46 am

Re: Using GdPicture in MFC

Post by AllanS » Thu Oct 17, 2013 4:08 am

Thanks! That works.
So i'm trying to mess around with the program more and having trouble.

CGdPictureImaging.CreateGdPictureImageFromByteArray(SAFEARRAY** Data)

This takes in a SafeArray, below is my code.
When I ran it, the function returns "the parameter is incorrect".
I'm developing in VS 2005, that's why I'm using COleSafeArray instead of CComSafeArray

CGdPictureImaging gdImaging;
COleSafeArray saPhoto;
// lSizeOfMyByteArray is long and lpMyByteArray is BYTE FAR*
saPhoto.CreateOneDim(VT_UI1, (DWORD)lSizeOfMyByteArray, lpMyByteArray); // I've tried VT_I4 as well
long lImageID = gdImaging.CreateGdPictureImageFromByteArray(&psa);

I'm also trying to save the resulting image into memory, would you recommend using SaveAsStream or SaveAsByteArray?
I see that SaveAsStream outputs LPDISPATCH, how do I go about converting that into a usable format?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest