Jump to content
Sign in to follow this  
taurus

bad transparency layer?

Recommended Posts

; PNG work around by Zedna

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <WindowsConstants.au3>

; Create GUI
Global $g_hGUI = GUICreate("Show PNG", 512, 512, -1, -1, -1, $WS_EX_LAYERED)
GUISetBkColor(0xff00ff)
_WinAPI_SetLayeredWindowAttributes($g_hGUI, 0xff00ff, 255)

; Load PNG image
_GDIPlus_Startup()
Global $g_hImage = _GDIPlus_ImageLoadFromFile("logo.png")
Global $g_hGraphic = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)

GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

; Clean up resources
_GDIPlus_GraphicsDispose($g_hGraphic)
_GDIPlus_ImageDispose($g_hImage)
_GDIPlus_Shutdown()

; Draw PNG image
Func MY_WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW)
    _GDIPlus_GraphicsDrawImage($g_hGraphic, $g_hImage, 0, 0)
    _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_VALIDATE)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_PAINT

IMAGE :: 

http://www.hooddonz.com/uploads/3/4/9/0/3490457/3227883.png

 

and here is my problem :: 

T4ejOGT.jpg

all that pink outline is ugly as hell , how can i fix that? 

Share this post


Link to post
Share on other sites

You can use a brighter transparent / bg color, e.g. 0xF1F1F1.

What do you want to code? Just displaying an image? Or adding additional controls to the GUI?


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

just display the image and a countdown timer in middle on top of the image. thats all.

PS : i tryed brighter background , but it looks ugly on darker backgrounds now. :)

 

EDIT : There must be "cleaner" way to get rid of that terrible *antialiasing* around the image? i have been struggling with this problem for years to be honest.

Edited by taurus

Share this post


Link to post
Share on other sites

Then try this:

; PNG work around by Zedna

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>


Global Const $SC_DRAGMOVE = 0xF012
; Create GUI
Global $g_hGUI = GUICreate("Show PNG", 512, 512, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
Global $g_hGUI_Child = GUICreate("", 512, 512, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $g_hGUI)
GUISetBkColor(0x888888, $g_hGUI_Child)
Global $iLabel = GUICtrlCreateLabel("", 200, 200, 112, 32, BitOR($SS_CENTERIMAGE, $SS_CENTER))
GUICtrlSetFont(-1, 20, 400, 0, "Arial", 6)
GUICtrlSetColor(-1, 0xF0F0F0)
GUICtrlSetBkColor(-1, 0x404040)
GUISetState(@SW_SHOW, $g_hGUI)
GUISetState(@SW_SHOW, $g_hGUI_Child)
_WinAPI_SetLayeredWindowAttributes($g_hGUI_Child, 0x888888)

; Load PNG image
_GDIPlus_Startup()
Global $g_hImage = _GDIPlus_ImageLoadFromFile("logo.png")
;~ Global $g_hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("http://www.hooddonz.com/uploads/3/4/9/0/3490457/3227883.png"))
Global $g_hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_hImage)
_WinAPI_UpdateLayeredWindowEx($g_hGUI, -1, -1, $g_hGDIBitmap, 255, True)

GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
AdlibRegister("Timer", 1000)

; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

AdlibUnRegister("Timer")
; Clean up resources
_GDIPlus_ImageDispose($g_hImage)
_WinAPI_DeleteObject($g_hGDIBitmap)
_GDIPlus_Shutdown()
GUIDelete()

Func Timer()
    GUICtrlSetData($iLabel, @SEC)
EndFunc


Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    _SendMessage($g_hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc   ;==>_WM_LBUTTONDOWN
Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...