1

I am trying to make a PNG to ICON converter, just to practice Windows Imaging Component, I have run into a problem concerning the CreateEncoder function of IWICImagingFactory.

IWICBitmapEncoder* encoder;
HRESULT res = imgFactory->CreateEncoder(GUID_ContainerFormatIco, &vendor, 
&encoder);
std::cout << _com_error(res).ErrorMessage() << std::endl;

This gives an error in HRESULT, with the message "The component cannot be found," what's interesting is this only happens with GUID_ContainerFormatIco, If I try and convert to Tiff, or Jpeg it works completely fine.

So, why can I not create a WICBitmapEncoder that encodes .ico files? I was hypothesizing it might be something to do with icon restrictions (because icons may have to be 32x32, 16x16) this could make it less straightforward, i am not sure though.

nedb
  • 586
  • 1
  • 4
  • 12
  • From the [horse's mouth](https://msdn.microsoft.com/en-us/library/windows/desktop/gg430024(v=vs.85).aspx): "_WIC does not provide a native ICO encoder_". You might consider writing your own; the file format is not particularly complex. No doubt there are ready-made alternatives for you, though. – Rook Jun 09 '17 at 18:38
  • Interestingly, it appears that GDI+ does not support ICO encoding either, so there's no microsoft-provided way to save ICO files. I can't imagine why not, but there you go. – Rook Jun 09 '17 at 18:46
  • Ok, thanks, I will create my own. Why does GUID_ContainerFormatIco actually exist though? – nedb Jun 09 '17 at 19:08
  • 2
    If you look at the MSDN page it supports decoding. – zett42 Jun 09 '17 at 19:29
  • The answers to [this question](https://stackoverflow.com/q/2289894/7571258) have code to write ICO files. – zett42 Jun 09 '17 at 19:46

0 Answers0