News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

WIC tests

Started by TimoVJL, November 03, 2022, 10:08:33 AM

Previous topic - Next topic

TimoVJL

WIC enum#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;
}
BMP Decoder
GIF Decoder
ICO Decoder
JPEG Decoder
PNG Decoder
TIFF Decoder
WMPhoto Decoder
BMP Decoder
GIF Decoder
ICO Decoder
JPEG Decoder
PNG Decoder
TIFF Decoder
WMPhoto Decoder
WebP Decoder

EDIT: zip with smaller files using msvcrt.dll
May the source be with you

Biterider

Hi
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


Biterider


TimoVJL

Nice you got those additional codecs too :thup:
Windows 10 22H2BMP Decoder
GIF Decoder
ICO Decoder
CUR Decoder
JPEG Decoder
PNG Decoder
TIFF Decoder
DNG Decoder
WMPhoto Decoder
DDS Decoder
Microsoft Camera Raw Decoder

Additional codecs can be found from Microsoft Store ?
May the source be with you

TimoVJL

More tests#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;
}
May the source be with you

jj2007

Win7-64:
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}


..test64.exe crashes.

TimoVJL

If WIC_test164.exe chrash, what file was in command file ?
May the source be with you

jj2007

Photoshop Codec:
C:\Masm32\MasmBasic>WICImagingFactoryTest.exe
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}

C:\Masm32\MasmBasic>WICImagingFactoryTest64.exe
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}

TimoVJL

In some Windows 10BMP Decoder     {6B462062-7CBF-400D-9FDB-813DD10F2778}
GIF Decoder     {381DDA3C-9CE9-4834-A23E-1F98F8FC52BE}
ICO Decoder     {C61BFCDF-2E0F-4AAD-A8D7-E06BAFEBCDFE}
CUR Decoder     {22696B76-881B-48D7-88F0-DC6111FF9F0B}
JPEG Decoder    {9456A480-E88B-43EA-9E73-0B2D9B71B1CA}
PNG Decoder     {389EA17B-5078-4CDE-B6EF-25C15175C751}
TIFF Decoder    {B54E85D9-FE23-499F-8B88-6ACEA713752B}
DNG Decoder     {981D9411-909E-42A7-8F5D-A747FF052EDB}
WMPhoto Decoder {A26CEC36-234C-4950-AE16-E34AACE71D0D}
DDS Decoder     {9053699F-A341-429D-9E90-EE437CF80C73}
Microsoft HEIF Decoder  {E9A4A80A-44FE-4DE4-8971-7150B10A5199}
Microsoft Webp Decoder  {7693E886-51C9-4070-8419-9F70738EC8FA}
Microsoft Raw Image Decoder     {41945702-8302-44A6-9445-AC98E8AFA086}
Microsoft Camera Raw Decoder    {5FDD51E2-A9D0-44CE-8C8D-162BA0C591A0}
May the source be with you

jj2007

The crash at 000007FEFAB68E41 (stack misaligned):
000007FEFAB68E1C | 66:0F6F05 7C950100         | movdqa xmm0,[7FEFAB823A0]       |
000007FEFAB68E24 | 66:0F6F0D F48E0100         | movdqa xmm1,[7FEFAB81D20]       |
000007FEFAB68E2C | 4C:8D4424 20               | lea r8,[rsp+20]                 |
000007FEFAB68E31 | 48:8D4D D0                 | lea rcx,[rbp-30]                |
000007FEFAB68E35 | BA 04010000                | mov edx,104                     |
000007FEFAB68E3A | C745 80 00000000           | mov [rbp-80],0                  |
000007FEFAB68E41 | 66:0F7F4424 20             | movdqa [rsp+20],xmm0            | RSP=12F628
000007FEFAB68E47 | 66:0F7F4C24 30             | movdqa [rsp+30],xmm1            |
000007FEFAB68E4D | C645 84 00                 | mov [rbp-7C],0                  |
000007FEFAB68E51 | 0F57C0                     | xorps xmm0,xmm0                 |
000007FEFAB68E54 | 0F57C9                     | xorps xmm1,xmm1                 |
000007FEFAB68E57 | 66:0F7F4424 40             | movdqa [rsp+40],xmm0            |
000007FEFAB68E5D | 66:0F7F4C24 50             | movdqa [rsp+50],xmm1            |
000007FEFAB68E63 | 66:0F7F4424 60             | movdqa [rsp+60],xmm0            |
000007FEFAB68E69 | 66:0F7F4C24 70             | movdqa [rsp+70],xmm1            |
000007FEFAB68E6F | E8 8C350000                | call 7FEFAB6C400                |
000007FEFAB68E74 | 48:8D55 D0                 | lea rdx,[rbp-30]                |
000007FEFAB68E78 | 48:8D0D 51730100           | lea rcx,[7FEFAB801D0]           | 000007FEFAB801D0:"\n %s"
000007FEFAB68E7F | E8 CC330000                | call 7FEFAB6C250                |
000007FEFAB68E84 | FF15 3E820100              | call [<&GetCurrentProcessId>]   |
000007FEFAB68E8A | FF15 28820100              | call [<&GetCommandLineA>]       |
000007FEFAB68E90 | E8 4B000000                | call <flushWrapperControlCache> |

Biterider

Hi TimoVJL
On my Win10, WIC_Test1 doesn't produce any output and WIC_Test164 crashes.

Biterider

Vortex

Hi Timo,

WIC_Test164 does not crash on my Win7 64-bit system but no any ouput on the console.  Also, no any output from WIC_test1.exe

TimoVJL

#11
Good to hear, that severals got examples chrashed in this site.
I tested examples with Window 7 x64, EN version, PC using AMD CPU.
For me examples works with different picture files.

For testing:
WIC_test1_msvc2022.exe

>WIC_test1_msvc2022x64.exe 1.sm.webp
pDecoder created
pFrame created
{6FDDC324-4E03-4BFE-B185-3D77768DC90F}
320 214

May the source be with you

jj2007


TimoVJL

WIC_test1 using poasm
May the source be with you

Biterider

Hi TimoVJL
No output from cmd prompt on Win10...

Biterider