AutoHotkey Community

It is currently May 26th, 2012, 6:26 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: February 16th, 2009, 12:04 am 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
I have created some images to use as buttons.
They are not displaying exactly as they should.

I am displaying them from a .dll file, as shown by SKAN, here:

http://www.autohotkey.com/forum/viewtopic.php?t=9980&postdays=0&postorder=asc&start=15


Code:
addcheckbox(cb_var,cb_color,options,cb_on =false,cb_gui =1,cb_subroutine ="togglecheckboxpng")
{
   global
   static handlecount
   if handlecount<1
      handlecount=1
   handlecountplus:=handlecount+1
   cb_temppic1:="cb_pic" . handlecount
   cb_temppic2:="cb_pic" . handlecountplus   
   Gui, %cb_gui%:Add, Text,g%cb_subroutine% v%cb_var%onn  %options% +0xE hWnd%cb_temppic1% ; +0xE is SS_BITMAP
   cbt1:=%cb_temppic1%
   
   Gui, %cb_gui%:Add, Text,g%cb_subroutine% v%cb_var%off %options% xp yp +0xE hWnd%cb_temppic2% ; +0xE is SS_BITMAP    
   displaypng(%cb_temppic1%,%cb_color%checkboxoniconum)
   displaypng(%cb_temppic2%,%cb_color%checkboxofficonum)
   if cb_on
   {
      guicontrol,hide,% cb_var . "off"
      %cb_var%:=true
      
   }
   
   handlecount+=2
   return
}

displaypng(pic,resourceno) ; DISPLAYS A PNG FROM A RESOURCE FILE
{
   global hModule
   LoadResourceImage(resourceno,pic,hModule)
   return
}


LoadResourceImage(ResNo,hImage,ByRef hModule,x =0,y =0)
{
   global hBitmap
   ;msgbox,,,%hBitmap%::%resno%::%hImage%:::%hModule%
    DllCall( "DeleteObject", UInt,hBitmap )
  hJpegData := GetResource( hModule, ResNo, 10, nSize, hresData )
  DllCall( "FreeResource", UInt,hResData )
  hBitmap := gdiBitmap( hJpegData, nSize, wxh )
  if ((x<>0) or (y<>0))
  {
   new_hBitmap := DllCall("CopyImage",UInt, hBitmap,UInt,0,Int,x,Int,y, UInt,0)
   hBitmap:=new_hBitmap
   new_hBitmap:=""
  }
  SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hImage%
Return                                         
  }


GetResource( hModule, rName, rType, ByRef nSize, ByRef hResData ) {
  hResource := DllCall( "FindResource", UInt,hModule, UInt,rName, UInt,rType )
  nSize     := DllCall( "SizeofResource", UInt,hModule, UInt,hResource )
  hResData  := DllCall( "LoadResource", UInt,hModule, UInt,hResource )
Return DllCall( "LockResource", UInt, hResData )
}

gdiBitmap( Buffer, nsize, byref wxh ) {
; Sean : http://www.autohotkey.com/forum/viewtopic.php?p=147029#147029
  hData := DllCall("GlobalAlloc", UInt,2, UInt, nSize )
  pData := DllCall("GlobalLock",  UInt,hData )
  DllCall( "RtlMoveMemory", UInt,pData, UInt,Buffer, UInt,nSize )
  DllCall( "GlobalUnlock", UInt,hData )
  DllCall( "ole32\CreateStreamOnHGlobal", UInt,hData, Int,True, UIntP,pStream )
  DllCall( "gdiplus\GdipCreateBitmapFromStream", UInt,pStream, UIntP,pBitmap )
  DllCall( "gdiplus\GdipCreateHBITMAPFromBitmap", UInt,pBitmap, UIntP,hBitmap, UInt,8 )
  DllCall( "gdiplus\GdipGetImageWidth" , "Uint", pBitmap, "UintP", nW)
  DllCall( "gdiplus\GdipGetImageHeight", "Uint", pBitmap, "UintP", nH), wxh := nW "x" nH
  DllCall( "gdiplus\GdipDisposeImage", UInt,pBitmap )
return hbitmap
}


Here is what it should look like:
Image
And here is what it displays as:

Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 21st, 2009, 11:54 pm 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
I have discovered that transparent colors are displaying as black.

When I created a completely transparent image for a button (png file), it displayed as black. Why is this?

I created the image in Inkscape, and exported it as a .png.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: From IRC
PostPosted: November 27th, 2011, 11:21 am 
[05:06] <Werner_ML> i'm having some real trouble here
[05:06] <Werner_ML> =[
[05:06] <Werner_ML> http://www.flickr.com/photos/wernerml/6410172617/
[05:06] <Werner_ML> http://www.flickr.com/photos/wernerml/6410172533/
[05:06] <Werner_ML> black transparency in a .png
[05:06] <Werner_ML> i'm trying everything for the last 4 hours
[05:07] <Werner_ML> =[
[05:07] <Werner_ML> I think this is a specific problem from a Windows 7 here...
[05:07] <Werner_ML> the others (computers) work fine
[05:07] <TodWulff> !transparency win7
[05:07] <robokins> Found "WINDOWS 7 PROBLEM: Gui Disappears after SetParent": http://ahk.me/sXfZl3
[05:07] <TodWulff> fail
[05:07] <Werner_ML> =]
[05:07] <Werner_ML> sheheh
[05:08] * TodWulff hasn't made the jump to win7 yet - sry
[05:08] <Werner_ML> it's BLACK, when it supposed to be transparent...
[05:08] <Werner_ML> maybe I'll have to use GDI+
[05:08] <Werner_ML> =/
[05:08] <Werner_ML> but it's just a .png in the background of controls, to make them look nice
[05:08] <Werner_ML> =/
[05:09] <TodWulff> yeah, I get the issue, just no experiece with it.
[05:09] <Werner_ML> too much work, too much resources running, with a GDI just for that
[05:09] <TodWulff> ding ding
[05:09] <TodWulff> agreed
[05:09] <Werner_ML> i think it's my sisters broken system here
[05:09] <Werner_ML> even in a WinXP its working
[05:09] <TodWulff> did u search the forums?
[05:10] <Werner_ML> yeah
[05:10] <Werner_ML> i found the same issue, but nobody answer
[05:10] <TodWulff> ugh. Idle here, maybe someone can chime in - pretty skilled folks hang herein...
[05:11] <Werner_ML> http://www.autohotkey.com/forum/topic41051.html
[05:11] <Werner_ML> yeah
[05:11] <Werner_ML> i'll continue programming
[05:11] <Werner_ML> then
[05:11] <Werner_ML> thanks
[05:11] *** Werner_ML changed nick to Werner_[coding]
[05:12] <TodWulff> Werner_[coding], you could also reply to that thread and see if someone is able to offer responsive guidance.?.
[05:12] <Werner_[coding]> OOOO MMYY GOOOOODDDDDDDDDD
[05:12] <NameLess-exe> ?
[05:12] <Werner_[coding]> CAN'T BELIEVE
[b][05:12] <Werner_[coding]> it was 16 bit colors, the system[/b]
[05:12] <TodWulff> lol
[05:12] <Werner_[coding]> my sister's windows
[05:12] <Werner_[coding]> LOL
[05:12] <Werner_[coding]> =/
[05:12] <Werner_[coding]> spend hours trying to solve this
[05:12] <Werner_[coding]> hehehehe
[05:13] <TodWulff> now you know...


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], rbrtryn, SKAN and 54 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group