IImagingFactory IImage Problem

  • Thread starter Thread starter CodeFatal
  • Start date Start date
C

CodeFatal

Hello,

I'm new here, please forgive if this is the wrong newsgroup.

I write a little programm wich handle with JPG-Files. The destination
plattform is Win CE 5.0.
I build the code with eMbedded Visual Studio c++ 4.0.

I had created the following Code:

LoaderFunktion:
IImagingFactory *pFactory=NULL;
IImage *pImage=NULL;
ImageInfo *info =NULL;

HRESULT hr = CoCreateInstance(CLSID_ImagingFactory, NULL,
CLSCTX_INPROC_SERVER,__uuidof(IImagingFactory),(void **)&pFactory);
if(FAILED(hr))
{
return FALSE;
}

hr = pFactory->CreateImageFromFile(Pfad, &pImage);

if ( FAILED ( hr ) )
{
pFactory->Release();
return FALSE;
}

info = new ImageInfo;
if(!info)
{
pFactory->Release();
return FALSE;
}
pImage->GetImageInfo(info);
//imageInf and Image are Pointer to Save the Data
ImageInf = (void*) info;
Image = (void*)pImage;


pFactory->Release();

DrawFunktion:
IImage *pImage = Image;
pImage->Draw(...);

DeleteFunktion
delete ImageInf;
delete Image;


The problem:

Everything works fine but wenn i had load some Pictures no one more
will be show.

The Funktion CreateImageFromFile return with code :0x80070008
I think the Problem is the DeleteFunktion. But I haven't found any
thing to delete the data correctley.

Someone here to help me?

Thanks Michael
 
I never found a solution for this either. I agree I think it is in the COM
object dispose somewhere.

I ended up launching a seperate process to create my image.

Use one of the many options for IPC to pass it back to you main app.
 
Yo can't possibly use delete with an interface pointer. You must call
pImage->Release()
 
Thanks.
I've suspect such a mistake.
It seems to work.

Can I use delete for ImageInfo? I use new to create it.

Do you have some more help sites as the official microsoft one?

Michael
 
Can I use delete for ImageInfo? I use new to create it.

You have to delete ImageInfo; otherwise you will have memory leaks.

The IImage should be released because it's COM Interface. Each COM
interface inherits from IUnknown interface. This interface contains
AddRef (increments the reference count) and Release (decrement count,
when its value is zero the object become freed).
 
Back
Top