Page 1 of 2

Images with shadows/reflection in toolbar?

Posted: Mon May 19, 2008 7:02 pm
by ricardo
Hello

Im creating a toolbar (in this case in ProGUI, but i think question is the same) and i want to use a set of quality icons (i have it in PNG), something like:

Image

Image

Image

My question is, how can i use it in imagebuttons or toolbar without lossing the nice shadow, transparency or even reflection efect? Is possible?

Thanks in advance

Posted: Mon May 19, 2008 7:04 pm
by Num3
AFAIK, if you use 32bit icons with alpha the images will look just like that!

Posted: Mon May 19, 2008 7:19 pm
by ricardo
Its possible using PNG? (But keeping transparency and shadows)?

Posted: Mon May 19, 2008 7:44 pm
by Trond
Yes, but it does only work on XP and newer.

Posted: Mon May 19, 2008 7:48 pm
by Nico
You have to transform your image png into icon with alpha, it will work under XP with the activated Theme.

Posted: Tue May 20, 2008 12:14 am
by ricardo
Trond wrote:Yes, but it does only work on XP and newer.
I think thats okay, i guess almost no one is using OS older than XP, im right?

Posted: Tue May 20, 2008 12:15 am
by ricardo
Nico wrote:You have to transform your image png into icon with alpha, it will work under XP with the activated Theme.
Photoshop? I tried with "Picture to Icon" trial and the shadow shows ugly (or maybe im a bad graphic manipulator :( )

Posted: Tue May 20, 2008 3:11 am
by ricardo
For the records (if anybody in the future want to solve this same problem).

Dld a freeware plugin that let you open any image with alpha channel and save it as ico. (i use it in photoshop and works like a charm)

http://www.telegraphics.com.au/svn/icof ... EADME.html

Posted: Tue May 20, 2008 10:01 am
by Trond
As said above: you do not need to convert it to icon. Just use the png file directly.

Posted: Tue May 20, 2008 12:16 pm
by milan1612
I use the Axialis IconWorkshop trial to convert PNGs to Icons. It handles transparency
very well and you can specify the size quite straightforward.
Really worths a look...

Posted: Tue May 20, 2008 1:07 pm
by ricardo
Trond wrote:As said above: you do not need to convert it to icon. Just use the png file directly.
And it shows the alpha?
Did you have an example (because i was not able to do it)?

Thanks

Posted: Tue May 20, 2008 3:56 pm
by Trond

Code: Select all

UsePNGImageDecoder()

OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
CreateToolBar(0, WindowID(0))
ToolBarImageButton(0, LoadImage(0, "c:\map.png"))

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver
Image: http://img139.imageshack.us/img139/451/mapfi5.png

Posted: Tue May 20, 2008 4:26 pm
by mrjiles
No alpha here... I've always had to convert to .ico. Sometimes I cannot even get the fancy icons to show when in .ico format.

Posted: Tue May 20, 2008 5:49 pm
by ricardo
@Trond:

You are right!

Here is some modified code i test for using 48x48 images.

Code: Select all

;Modified from Sparkie's code

#TB_SETIMAGELIST = #WM_USER + 48
#TB_GETIMAGELIST = #WM_USER + 49

UsePNGImageDecoder() 

Procedure MakeLong(lo.w, hi.w)
  ProcedureReturn (hi * $10000) | (lo & $FFFF)
EndProcedure

;Your own 48x48 png images for toolbar with alpha showing
LoadImage(0, "F:\Inconos Alta Calidad\48x48\accept.png")
LoadImage(1, "F:\Inconos Alta Calidad\48x48\add.png")
LoadImage(2, "F:\Inconos Alta Calidad\48x48\attachment.png")

If OpenWindow(0, 0, 0, 350, 250,"", #PB_Window_SystemMenu |#PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  hTB = CreateToolBar(0, WindowID(0))
  hOldIList = SendMessage_(hTB, #TB_GETIMAGELIST, 0, 0);
  hNewIList = ImageList_Duplicate_(hOldIList)
  ImageList_Destroy_(hOldIList)
  ImageList_SetIconSize_(hNewIList, 48, 48)
  SendMessage_(hTB, #TB_SETIMAGELIST, 0, hNewIList)
  SendMessage_(hTB, #TB_SETBITMAPSIZE, 0, MakeLong(48,48))
  SendMessage_(hTB, #TB_SETBUTTONSIZE, 0, MakeLong(48,48))
  SendMessage_(hTB, #TB_AUTOSIZE, 0, 0)
  ToolBarImageButton(0, ImageID(0))
  ToolBarImageButton(1, ImageID(1))
  ToolBarImageButton(2, ImageID(2))
  Repeat
    EventID = WaitWindowEvent()
    If EventID = #PB_Event_Menu
    EndIf
  Until EventID = #PB_Event_CloseWindow
  ImageList_Destroy_(hNewIList)
EndIf 

Posted: Wed May 21, 2008 9:10 am
by DoubleDutch
Don't forget that if in XP they turn off themes then it will look bad.

You should have 2 sets of icons - one in 256 colours for if they don't have themes turned on.