Jump to content

Bug or Feature?


 Share

Recommended Posts

Hi All,

I discovered today having the color #F0F0F0 within a image causes it become transparent.

#NoTrayIcon
#include <GUIConstantsEx.au3>
GUICreate("AutoIt Test", 500, 500)
GUISetBkColor(0xE0FFFF) 
GUICtrlCreatePic(@ScriptDir & "\Test.bmp", 0, 0, 500, 500)
GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

From other code that makes a GUI transparent _WinAPI_SetLayeredWindowAttributes() it needs to match a color, so this does make sense. 

This also explains why in the helpfile for  GUICtrlCreatePic() it says;

"The background is always set to transparent. GUICtrlSetBkColor() has no effect on pic control."

Just wanted to double check this is more a feature then bug :)

 

test.bmp

Edited by IanN1990
Link to comment
Share on other sites

I've tested your code with you image and shows no such effect  ( AutoIt v3.3.14.5 ) 
Yes, the image shows as of a transparent image.

PS: ..and the behavior shows on every version of AutoIt3 ( tested all the way back to v3.2.0.1 ).

Edited by argumentum
I was wrong

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

You had me doubting then!

I am running v3.3.14.2 on Windows 7 Pro (and tested on windows 8). I also discovered for this effect to happen the image must not be resized. 

The main reason i am asking is because i am thinking of replacing my current transparency code for this instead. As then it doesn't require GDIPlus, is fewer lines and seems to display it better (no outline).

Current Version

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <winapi.au3>
#include <GDIPlus.au3>

$STM_SETIMAGE = 0x0172

_GDIPlus_Startup()
$hGui = GUICreate("AutoIt Test", 241, 60, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0x000000)
$hPic = GUICtrlCreatePic("", 0, 0, 241, 60)

$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\test.png")
$hBitmap = _GDIPlus_BitmapCloneArea($hImage, 0, 0, 241, 60, $GDIP_PXF32ARGB)
$hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_ImageDispose($hImage)
GUICtrlSendMsg($hPic, $STM_SETIMAGE, 0, $hBmp)
_WinAPI_DeleteObject($hBmp)

_WinAPI_SetLayeredWindowAttributes($hGui, 0x000000, 255)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _GDIPlus_Shutdown()
            ExitLoop
    EndSwitch
WEnd

test.png

Proposed version

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <winapi.au3>
$hGui = GUICreate("AutoIt Test", 241, 60, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0x000000)
GUICtrlCreatePic(@ScriptDir & "\test.bmp", 0, 0, 241, 60)
GUISetState()

_WinAPI_SetLayeredWindowAttributes($hGui, 0x000000, 255)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

test.bmp
 

Edited by IanN1990
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...