Pelles C forum

C language => Graphics programming => Topic started by: leandrojardim on April 25, 2012, 11:04:34 pm

Title: How to use Windows Imaging Framework
Post by: leandrojardim on April 25, 2012, 11:04:34 pm
I have this code as seen in MSDN:

Code: [Select]
#include <windows.h>
#include <wincodec.h>

void foobar (void) {
HRESULT Result = 0;
IWICImagingFactory *Factory = NULL;

CoInitialize(NULL);
Result = CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, IID_PPV_ARGS(&Factory));

D:\Documentos do Leandro\Pelles C Projects\Alien - Cópia\ball.c(255): error #2140: Type error in argument 1 to 'CoCreateInstance'; expected 'LPCGUID const' but found 'UOW'.
D:\Documentos do Leandro\Pelles C Projects\Alien - Cópia\ball.c(255): error #2140: Type error in argument 4 to 'CoCreateInstance'; expected 'LPCGUID const' but found 'UOW'.
D:\Documentos do Leandro\Pelles C Projects\Alien - Cópia\ball.c(255): warning #2018: Undeclared function 'IID_PPV_ARGS'; assuming 'extern' returning 'int'.
D:\Documentos do Leandro\Pelles C Projects\Alien - Cópia\ball.c(255): error #2140: Type error in argument 5 to 'CoCreateInstance'; expected 'void * *' but found 'int'.

But it doesnt compile. What do I need to modify to make it work as expected?

Thanks!
Title: Re: How to use Windows Imaging Framework
Post by: TimoVJL on April 26, 2012, 07:27:14 am
You example was for C++.
So
Code: [Select]
#define IID_PPV_ARGS(ppType) ((void**)(ppType))
Result = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, IID_PPV_ARGS(&Factory));
or
Code: [Select]
Result = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void**)&Factory);
Title: Re: How to use Windows Imaging Framework
Post by: leandrojardim on April 27, 2012, 01:57:37 am
Thanks, timo!  :)
Title: Re: How to use Windows Imaging Framework
Post by: _SIL_ on August 07, 2012, 04:19:38 pm
Is there a way to use IWICImagingFactory or  IImagingFactory on WinCe???
In winmobile SDK no wincodec.h. Need help!
Title: Re: How to use Windows Imaging Framework
Post by: TimoVJL on August 07, 2012, 05:18:05 pm
Quote
IImagingFactory on WinCe???
Requirements

OS Versions: Windows CE 5.0 and later.
Header: Imaging.h
Link Library: Imaging.lib

It is COM based and Imaging.h is for C++ only.

http://msdn.microsoft.com/en-us/library/aa452202 (http://msdn.microsoft.com/en-us/library/aa452202)
http://www.microsoft.com/en-us/download/details.aspx?id=17310 (http://www.microsoft.com/en-us/download/details.aspx?id=17310)
Title: Re: How to use Windows Imaging Framework
Post by: _SIL_ on August 07, 2012, 05:56:02 pm
Thanks, timovjl.
I need only draw several *png with transparency on my form. In evc4 i have worked sample, but i like pelles more than evc.
Maybe you can suggest me easy way to do that in pelles с ? ???
Target prog is very simple so i would't want to overload by libpng or cximage librarys....

Title: Re: How to use Windows Imaging Framework
Post by: Stefan Pendl on August 07, 2012, 06:01:59 pm
How about using GDI+ instead, if that is available on WinCE?
Title: Re: How to use Windows Imaging Framework
Post by: TimoVJL on August 07, 2012, 10:12:31 pm
Here is simple example with partially converted header file.
Title: Re: How to use Windows Imaging Framework
Post by: _SIL_ on August 08, 2012, 09:43:20 am
Here is simple example with partially converted header file.
Wow! You Great! Compilled sample work fine!

Can you show your ImgTest.h? Please!!!
Title: Re: How to use Windows Imaging Framework
Post by: TimoVJL on August 08, 2012, 12:35:35 pm
Oops, but now it is in that zip.
Title: Re: How to use Windows Imaging Framework
Post by: _SIL_ on August 08, 2012, 01:22:43 pm
Many, many thanks!!!
Work fine with CreateImageFromStream() too.

For using GetImageInfo() ImgTest.h also need that
Code: [Select]
typedef INT PixelFormat;

struct ImageInfo{
    GUID RawDataFormat;
    PixelFormat PixelFormat;
    UINT Width, Height;
    UINT TileWidth, TileHeight;
    double Xdpi, Ydpi;
    UINT Flags;
};
Thanks!

-----
screen from my prog: http://lostpic.net/images/ccca17b85f423d928e4bcd61626f03dc.png