From 10c3830624454f37ce63982fee1b866fb7369b9b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 12 Mar 2014 23:04:00 +0000 Subject: [PATCH] Allow loading icons of width 256 from ICO files. Account for the tweak of ICO file format which uses 0 if the width is 256. See #15918. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76129 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/imagbmp.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/imagbmp.cpp b/src/common/imagbmp.cpp index 2675d8084f..127e0c41e5 100644 --- a/src/common/imagbmp.cpp +++ b/src/common/imagbmp.cpp @@ -1435,8 +1435,13 @@ bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream, alreadySeeked += stream.LastRead(); + // ICO file format uses only a single byte for width and if it is 0, it + // means that the width is actually 256 pixels. + const wxUint16 + widthReal = pCurrentEntry->bWidth ? pCurrentEntry->bWidth : 256; + // bHeight and bColorCount are wxUint8 - if ( pCurrentEntry->bWidth >= wMax ) + if ( widthReal >= wMax ) { // see if we have more colors, ==0 indicates > 8bpp: if ( pCurrentEntry->bColorCount == 0 ) @@ -1444,7 +1449,7 @@ bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream, if ( pCurrentEntry->bColorCount >= colmax ) { iSel = i; - wMax = pCurrentEntry->bWidth; + wMax = widthReal; colmax = pCurrentEntry->bColorCount; } }