
IdEntries: array of TIconDirEntry įunction ImageListAddIconEx(AImageList: TCustomImageList IdType: Word // resource type (1 for icons) This function returns index of the added icon in the image list if succeed, -1 otherwise: usesīHeight: Byte // image height, in pixelsīColorCount: Byte // number of colors in the image (0 if >= 8bpp)ĭwImageOffset: DWORD // image data offset If not, then the icon is added in a common way through the TIcon object. The processing first checks those 8 bytes if there's a PNG image on data offset position and if so, it adds this PNG image to the image list.

In the following code, the ImageListAddIconEx function iterates all the icons in the icon file and when there's one which matches the image list dimensions it is processed. What you can do to workaround this is to check, if there's the PNG signature on the first 8 bytes of the image data, which actually checks if there's a PNG image and if so, treat it as a PNG image, otherwise try to add the icon in a common way through the TIcon object. That's of course impossible (at this time :-) and happens just because the PNG file format icons doesn't have this bitmap header, but instead contains directly a PNG image on that position. If you take a look closer on the header values, you calculate that the system would try to create a bitmap which would be in size 169478669 * 218103808 pixels at 21060 B per pixel, what would need to have at least 778.5 EB (exabytes) of free memory :-)

The reason, why you are getting Out of system resources exception, is because the internally used procedures expects from icon to have a TBitmapInfoHeader structure and then tries to create a temporary bitmap based on this header information. Your icon is the PNG format file icon and those have no bitmap info header structure. The icon's bitmap info header is internally read in a different way than should be.

The fact, that the icon is a multi-size icon file doesn't matter in this case.
