Jump to content



Photo

Show a picture, that has transparency


  • Please log in to reply
2 replies to this topic

#1 Unc3nZureD

Unc3nZureD

    Polymath

  • Active Members
  • PipPipPipPip
  • 205 posts

Posted 07 June 2012 - 08:36 PM

I'm trying to make a software which has a part that shows a picture on your desktop. It has got some transparency too, so I must give a transparent color to the GUI.

Heres the pic: http://noob.hu/2012/06/07/protected.bmp (Black stuff is just a browser-bug)

Here's my current code:
#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> GUICreate("", 249, 73, 419, 289, $WS_POPUP, $WS_EX_TRANSPARENT) GUICtrlCreatePic(@ScriptDir & "protected.bmp", 0, 0, 248, 72) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg    Case $GUI_EVENT_CLOSE     Exit EndSwitch WEnd


When I run it there's a cream-like color around the pic (the default gui color). Any idea why it itsn't transparent? ($WS_EX_TRANSPARENT)

Edited by Unc3nZureD, 07 June 2012 - 08:38 PM.






#2 UEZ

UEZ

    Never say never

  • MVPs
  • 3,603 posts

Posted 07 June 2012 - 09:17 PM

This is a different bmp format which is even not displayed properly in GIMP or XnView. I would suggest to convert it to png.

PNG can be displayed properly even it has transparency using this function:

AutoIt         
Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF)     Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend     $hScrDC = _WinAPI_GetDC(0)     $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)     $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)     $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)     $tSize = DllStructCreate($tagSIZE)     $pSize = DllStructGetPtr($tSize)     DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))     DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))     $tSource = DllStructCreate($tagPOINT)     $pSource = DllStructGetPtr($tSource)     $tBlend = DllStructCreate($tagBLENDFUNCTION)     $pBlend = DllStructGetPtr($tBlend)     DllStructSetData($tBlend, "Alpha", $iOpacity)     DllStructSetData($tBlend, "Format", 1)     _WinAPI_UpdateLayeredWindow($hGUI,  $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)     _WinAPI_ReleaseDC(0, $hScrDC)     _WinAPI_SelectObject($hMemDC, $hOld)     _WinAPI_DeleteObject($hBitmap)     _WinAPI_DeleteDC($hMemDC) EndFunc   ;==>SetTransparentBitmap


Br,
UEZ

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#3 Unc3nZureD

Unc3nZureD

    Polymath

  • Active Members
  • PipPipPipPip
  • 205 posts

Posted 08 June 2012 - 05:43 AM

Okay, I will try, but I can see the pic in gimp perfectly (because I made it). And in AutoIT, that black stuff from behind goes away - I just want to hide the main Gui.

--------

Edit:
Converted to png - tried an other code - works perfectly ;) Thanks.

Edited by Unc3nZureD, 08 June 2012 - 05:50 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users