Win10 bug? CopyImage() w/ LR_CREATEDIBSECTION

Talk about things C/C++, some related to AutoHotkey
User avatar
Drugwash
Posts: 751
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Win10 bug? CopyImage() w/ LR_CREATEDIBSECTION

10 May 2019, 09:26

Recently when testing some old scripts of mine under Win10 x64 I noticed a couple of them were displaying their "skins" in color chunks instead of gradient as it always was the case from Win98SE to at least Win7. After some debugging I found out that the CopyImage() API was the culprit.

In fact it's the LR_CREATEDIBSECTION flag (value of 0x2000) that seems to behave in reverse. The function I use to stretch an ImageList bitmap from 2x5px to 140x36px uses a value of 0x2008 for the flags (LR_CREATEDIBSECTION | LR_COPYDELETEORG) and it has worked fine as mentioned above, however in Win10 CopyImage() fails to create the gradient when stretching if the LR_CREATEDIBSECTION flag is present.

Unfortunately, omitting that flag would make the bitmap "chunky" in all other Windows versions (tested only on XP SP3 so far but I'm pretty sure it would be the same on all older OSes). So, to me it appears that the functionality of the said flag - at least in conjunction with CopyImage() - has been (erroneously or on purpose?) reversed in Win10, maybe even in Win8.x.

I'd appreciate if anyone else had the time and will to test this and confirm (or not) my finding, or maybe it has already been found by someone else. It could be of help for fixing old AHK scripts that use CopyImage(), for Win10 compatibility, unless someone asks/reports the issue directly to Microsoft (if it indeed is a bug). Thank you.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.
User avatar
Drugwash
Posts: 751
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: Win10 bug? CopyImage() w/ LR_CREATEDIBSECTION

26 Aug 2019, 08:57

Really, nobody cared to test this in 3 1/2 months...? :(
Further, I noticed most recent versions of Wine have implemented the very same flag bahavior, breaking applications regardless of the OS version compatibility selected in winecfg. Am I going crazy or everything's slowly going down the drain?
swagfag
Posts: 3906
Joined: 11 Jan 2017, 17:59

Re: Win10 bug? CopyImage() w/ LR_CREATEDIBSECTION

26 Aug 2019, 12:50

post code(minimal working example)
post the resource
post what it looks like
post what it should look like
User avatar
Drugwash
Posts: 751
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Re: Win10 bug? CopyImage() w/ LR_CREATEDIBSECTION

12 Sep 2019, 13:22

Sorry for late reply, I haven't been notified of your message. :(

Not sure how minimal an example could be since this API is being used in conjunction with others. I'll atach one of my old scripts where I first noticed the issue. Funny thing is I can't find the most recent sources (could be on the XP machine, I'm on Linux Mint now) so I had to extract the script from the compiled exe; please excuse the lack of formatting.

Following screenshot was taken in VirtualBox, with same script first without LR_CREATEDIBSECTION (0x2000) and then with it. It's clear first image looks much better, as a smooth gradient. Using the same flag combination under Win9x/XP/7 (and maybe 8.x) would result in the exact reverse situation: first image ugly, second smooth.
CopyImage() flag bug.png
CopyImage() flag bug.png (21.96 KiB) Viewed 3026 times
Here's the code, look for the cif flag in the ILC_FitBmp2() function and switch it between 0x8 and 0x2008:
MemPanel_src.7z
(6.46 KiB) Downloaded 82 times
Please note that as it is now, the script would function correctly under all Windows versions, since I added that OSVersion detection and flag switch. But all old scripts making use of CopyImage() with the LR_CREATEDIBSECTION flag set will look bad. Which may even be intentional.
I've deleted my CloudMe account because of GDPR - the now legal base for privacy invasion and data theft.

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 6 guests