Re: Bug in HasAlpha()
Posted: Wed Apr 05, 2017 6:11 pm
If we paint it into a memory hDC then we will just check if it works or not
Nothing will be seen
Nothing will be seen
www.FiveTechSoft.com
https://forums.fivetechsupport.com/
Code: Select all | Expand
function HasAlpha( hBitmap )
local hDC := CreateDC( "DISPLAY", "", "" )
local lHasAlpha := ABPaint( hDC, 0, 0, hBitmap )
DeleteDC( hDC )
return lHasAlpha
Code: Select all | Expand
Harbour 3.2.0dev (r1605041350)
Copyright (c) 1999-2016, http://harbour-project.org/
Embarcadero C++ 7.20 for Win32 Copyright (c) 1993-2016 Embarcadero Technologies, Inc.
ALPHA.c:
Turbo Incremental Link 6.75 Copyright (c) 1997-2016 Embarcadero Technologies, Inc.
Error: Unresolved external '_pcre_config' referenced from E:\HARBOUR\LIB\HBRTL.LIB|hbregex
Error: Unresolved external '_pcre_stack_malloc' referenced from E:\HARBOUR\LIB\HBRTL.LIB|hbregex
Error: Unresolved external '_pcre_stack_free' referenced from E:\HARBOUR\LIB\HBRTL.LIB|hbregex
Error: Unable to perform link
Code: Select all | Expand
cFile := "c:\fwh\bitmaps\olga1.jpg"
hBmp := FILOADIMG( cFile ) // Source of function image.prg. Requires Freeimage.dll
? HasAlpha( hBmp ) // --> .F.
nageswaragunupudi wrote:Function HasAlpha() has never been changed and works the same way it was working all the time.Code: Select all | Expand
cFile := "c:\fwh\bitmaps\olga1.jpg"
hBmp := FILOADIMG( cFile ) // Source of function image.prg. Requires Freeimage.dll
? HasAlpha( hBmp ) // --> .F.
In the first post in this thread, hBmp is read wth the function GDIP_IMAGEFROMFILE(). This function uses GDI+. This does not require freeimage.dll, but the side-effect is this function converts even jpeg image as an alpha image and returns hBmp which has Alpha. Naturally HasAlpha( hBmp ) returns .T., because this hBitmap has Alpha channel. Even if the alpha channel is added ( 32-bit bitmap instead of 24-bit bitmap) there is no change in the content or rendering when painted with abpaint(). We knew this behavior from the time we started using GDI+.