Author Topic: WIC tests  (Read 829 times)

TimoVJL

  • Member
  • *****
  • Posts: 1259
WIC tests
« on: November 03, 2022, 10:08:33 AM »
WIC enum
Code: [Select]
#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;
}
Code: [Select]
BMP Decoder
GIF Decoder
ICO Decoder
JPEG Decoder
PNG Decoder
TIFF Decoder
WMPhoto Decoder
Code: [Select]
BMP Decoder
GIF Decoder
ICO Decoder
JPEG Decoder
PNG Decoder
TIFF Decoder
WMPhoto Decoder
WebP Decoder
EDIT: zip with smaller files using msvcrt.dll
« Last Edit: November 03, 2022, 10:04:21 PM by TimoVJL »
May the source be with you

Biterider

  • Member
  • *****
  • Posts: 1076
  • ObjAsm Developer
    • ObjAsm
Re: WIC tests
« Reply #1 on: November 03, 2022, 06:00:57 PM »
Hi
Code: [Select]
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

  • Member
  • *****
  • Posts: 1259
Re: WIC tests
« Reply #2 on: November 03, 2022, 08:29:26 PM »
Nice you got those additional codecs too :thup:
Windows 10 22H2
Code: [Select]
BMP 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

  • Member
  • *****
  • Posts: 1259
Re: WIC tests
« Reply #3 on: November 10, 2022, 01:57:34 AM »
More tests
Code: [Select]
#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

  • Member
  • *****
  • Posts: 13658
  • Assembly is fun ;-)
    • MasmBasic
Re: WIC tests
« Reply #4 on: November 10, 2022, 03:26:03 AM »
Win7-64:
Code: [Select]
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

  • Member
  • *****
  • Posts: 1259
Re: WIC tests
« Reply #5 on: November 10, 2022, 03:29:58 AM »
If WIC_test164.exe chrash, what file was in command file ?
May the source be with you

jj2007

  • Member
  • *****
  • Posts: 13658
  • Assembly is fun ;-)
    • MasmBasic
Re: WIC tests
« Reply #6 on: November 10, 2022, 03:32:50 AM »
Photoshop Codec:
Code: [Select]
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

  • Member
  • *****
  • Posts: 1259
Re: WIC tests
« Reply #7 on: November 10, 2022, 03:40:13 AM »
In some Windows 10
Code: [Select]
BMP 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

  • Member
  • *****
  • Posts: 13658
  • Assembly is fun ;-)
    • MasmBasic
Re: WIC tests
« Reply #8 on: November 10, 2022, 03:53:36 AM »
The crash at 000007FEFAB68E41 (stack misaligned):
Code: [Select]
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

  • Member
  • *****
  • Posts: 1076
  • ObjAsm Developer
    • ObjAsm
Re: WIC tests
« Reply #9 on: November 10, 2022, 04:17:07 AM »
Hi TimoVJL
On my Win10, WIC_Test1 doesn't produce any output and WIC_Test164 crashes.

Biterider

Vortex

  • Moderator
  • Member
  • *****
  • Posts: 2745
Re: WIC tests
« Reply #10 on: November 10, 2022, 05:02:58 AM »
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

  • Member
  • *****
  • Posts: 1259
Re: WIC tests
« Reply #11 on: November 10, 2022, 05:17:33 AM »
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

Code: [Select]
>WIC_test1_msvc2022x64.exe 1.sm.webp
pDecoder created
pFrame created
{6FDDC324-4E03-4BFE-B185-3D77768DC90F}
320 214
« Last Edit: November 10, 2022, 09:40:28 AM by TimoVJL »
May the source be with you

jj2007

  • Member
  • *****
  • Posts: 13658
  • Assembly is fun ;-)
    • MasmBasic
Re: WIC tests
« Reply #12 on: November 10, 2022, 06:55:54 AM »
For testing:
WIC_test1_msvc2022.exe

No output, no crash :rolleyes:

TimoVJL

  • Member
  • *****
  • Posts: 1259
Re: WIC tests
« Reply #13 on: November 16, 2022, 10:25:22 PM »
WIC_test1 using poasm
May the source be with you

Biterider

  • Member
  • *****
  • Posts: 1076
  • ObjAsm Developer
    • ObjAsm
Re: WIC tests
« Reply #14 on: November 16, 2022, 10:43:49 PM »
Hi TimoVJL
No output from cmd prompt on Win10...

Biterider