Projects > Pelle's C compiler and tools

WIC tests

(1/4) > >>

TimoVJL:
WIC enum
--- Code: ---#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ole2.h>
#include <wincodec.h>
#include <stdio.h>
#include <wchar.h>

#pragma comment(lib, "ole32")
//#pragma comment(lib, "windowscodecs.lib")
const GUID CLSID_WICImagingFactory = {0xcacaf262,0x9370,0x4615,{0xa1,0x3b,0x9f,0x55,0x39,0xda,0x4c,0xa}};
//const GUID CLSID_WICImagingFactory1 = {0xcacaf262,0x9370,0x4615,{0xa1,0x3b,0x9f,0x55,0x39,0xda,0x4c,0xa}};
//const GUID CLSID_WICImagingFactory2 = {0x317d06e8,0x5f24,0x433d,0xbd,0xf7,0x79,0xce,0x68,0xd8,0xab,0xc2};
const IID IID_IWICImagingFactory = {0xEC5EC8A9,0xC395,0x4314,{0x9C,0x77,0x54,0xD7,0xA9,0x35,0xFF,0x70}};
const IID IID_IWICBitmapCodecInfo = {0xE87A44C4,0xB76E,0x4C47,{0x8B,0x09,0x29,0x8E,0xB1,0x2A,0x27,0x14}};
// https://codexpert.ro/blog/2012/12/21/how-to-enumerate-wic-codecs/
// https://learn.microsoft.com/en-us/archive/msdn-magazine/2008/june/windows-with-c-decoding-windows-vista-icons-with-wic
int __cdecl main(void)
{
HRESULT hr;
IWICImagingFactory* pIWICFactory = 0;
//OleInitialize(NULL);
CoInitializeEx( NULL, COINIT_MULTITHREADED);
hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void **)(&pIWICFactory));
if (pIWICFactory) {
IEnumUnknown* pEnum;
DWORD dwOptions = WICComponentEnumerateDefault;
hr = pIWICFactory->lpVtbl->CreateComponentEnumerator(pIWICFactory, WICDecoder, dwOptions, &pEnum);
if(SUCCEEDED(hr))
{
UINT cbBuffer = 256;
ULONG cbActual = 0;
IUnknown* pElement = NULL;
WCHAR wszBuffer[256];
//while(S_OK == pEnum->lpVtbl->Next(pEnum, 1, &pElement, &cbActual))
while(S_OK == pEnum->lpVtbl->Next(pEnum, 1, &pElement, 0))
{
UINT cbActual2 = 0;
IWICBitmapCodecInfo* pCodecInfo;
hr = pElement->lpVtbl->QueryInterface(pElement, &IID_IWICBitmapCodecInfo, (void**)&pCodecInfo);
CLSID clsid;
hr = pCodecInfo->lpVtbl->GetCLSID(pCodecInfo, &clsid);
//hr = pCodecInfo->lpVtbl->GetFriendlyName(pCodecInfo, 0, NULL, &cbActual2);
hr = pCodecInfo->lpVtbl->GetFriendlyName(pCodecInfo, cbBuffer, wszBuffer, &cbActual2);
//wprintf(L"%Xh %u %ls\n", hr, cbActual2, wszBuffer);
wprintf(L"%ls\n", wszBuffer);
pElement = NULL;
}
}
pIWICFactory->lpVtbl->Release(pIWICFactory);
}
OleUninitialize();
return 0;
}

--- End code ---

--- Code: ---BMP Decoder
GIF Decoder
ICO Decoder
JPEG Decoder
PNG Decoder
TIFF Decoder
WMPhoto Decoder
--- End code ---

--- Code: ---BMP Decoder
GIF Decoder
ICO Decoder
JPEG Decoder
PNG Decoder
TIFF Decoder
WMPhoto Decoder
WebP Decoder
--- End code ---
EDIT: zip with smaller files using msvcrt.dll

Biterider:
Hi

--- Code: ---BMP Decoder
GIF Decoder
ICO Decoder
CUR Decoder
JPEG Decoder
PNG Decoder
TIFF Decoder
DNG Decoder
WMPhoto Decoder
DDS Decoder
Microsoft HEIF Decoder
Microsoft Webp Decoder
Microsoft Raw Image Decoder
Microsoft Camera Raw Decoder
--- End code ---

Biterider

TimoVJL:
Nice you got those additional codecs too :thup:
Windows 10 22H2
--- Code: ---BMP Decoder
GIF Decoder
ICO Decoder
CUR Decoder
JPEG Decoder
PNG Decoder
TIFF Decoder
DNG Decoder
WMPhoto Decoder
DDS Decoder
Microsoft Camera Raw Decoder
--- End code ---
Additional codecs can be found from Microsoft Store ?

TimoVJL:
More tests
--- Code: ---#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ole2.h>
#include <wincodec.h>
#include <stdio.h>
#include <wchar.h>

#pragma comment(lib, "ole32")
//#pragma comment(lib, "windowscodecs.lib")
const GUID CLSID_WICImagingFactory = {0xcacaf262,0x9370,0x4615,{0xa1,0x3b,0x9f,0x55,0x39,0xda,0x4c,0xa}};
//const GUID CLSID_WICImagingFactory1 = {0xcacaf262,0x9370,0x4615,{0xa1,0x3b,0x9f,0x55,0x39,0xda,0x4c,0xa}};
//const GUID CLSID_WICImagingFactory2 = {0x317d06e8,0x5f24,0x433d,0xbd,0xf7,0x79,0xce,0x68,0xd8,0xab,0xc2};
const IID IID_IWICImagingFactory = {0xEC5EC8A9,0xC395,0x4314,{0x9C,0x77,0x54,0xD7,0xA9,0x35,0xFF,0x70}};


int __cdecl wmain(int argc, wchar_t **argv)
{
HRESULT hr;
IWICImagingFactory *pIWICFactory = 0;
IWICBitmapDecoder *pDecoder = 0;
IWICBitmapFrameDecode *pFrame = 0;
OleInitialize(NULL);
hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (void **)(&pIWICFactory));
if (pIWICFactory) {
hr = pIWICFactory->lpVtbl->CreateDecoderFromFilename(pIWICFactory, argv[1], NULL, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &pDecoder );
if (pDecoder) {
puts("pDecoder created");
pDecoder->lpVtbl->GetFrame(pDecoder, 0, &pFrame );
if (pFrame) {
puts("pFrame created");
WICPixelFormatGUID pixelFormatGUID;
WCHAR wszBuffer[256];
pFrame->lpVtbl->GetPixelFormat(pFrame, &pixelFormatGUID );
StringFromGUID2(&pixelFormatGUID, wszBuffer, 255);
wprintf(wszBuffer);
UINT nWidth = 0;
UINT nHeight = 0;
pFrame->lpVtbl->GetSize(pFrame, &nWidth, &nHeight );
wprintf(L"\n%u %u\n", nWidth, nHeight);
pFrame->lpVtbl->Release(pFrame);
}
pDecoder->lpVtbl->Release(pDecoder);
}
pIWICFactory->lpVtbl->Release(pIWICFactory);
}
OleUninitialize();
return 0;
}

--- End code ---

jj2007:
Win7-64:

--- Code: ---BMP Decoder     {6B462062-7CBF-400D-9FDB-813DD10F2778}
GIF Decoder     {381DDA3C-9CE9-4834-A23E-1F98F8FC52BE}
ICO Decoder     {C61BFCDF-2E0F-4AAD-A8D7-E06BAFEBCDFE}
JPEG Decoder    {9456A480-E88B-43EA-9E73-0B2D9B71B1CA}
PNG Decoder     {389EA17B-5078-4CDE-B6EF-25C15175C751}
TIFF Decoder    {B54E85D9-FE23-499F-8B88-6ACEA713752B}
WMPhoto Decoder {A26CEC36-234C-4950-AE16-E34AACE71D0D}
Photoshop Codec {7AD07E2F-469A-4103-A9D4-C81C84CB3C79}
--- End code ---

..test64.exe crashes.

Navigation

[0] Message Index

[#] Next page

Go to full version