Images with shadows/reflection in toolbar?

Just starting out? Need help? Post your questions and find answers here.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Images with shadows/reflection in toolbar?

Post 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
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

AFAIK, if you use 32bit icons with alpha the images will look just like that!
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Its possible using PNG? (But keeping transparency and shadows)?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Yes, but it does only work on XP and newer.
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Post by Nico »

You have to transform your image png into icon with alpha, it will work under XP with the activated Theme.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post 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?
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post 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 :( )
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post 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
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

As said above: you do not need to convert it to icon. Just use the png file directly.
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post 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...
Windows 7 & PureBasic 4.4
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post 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
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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
mrjiles
Enthusiast
Enthusiast
Posts: 238
Joined: Fri Aug 18, 2006 7:21 pm
Location: IL

Post 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.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post 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 
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post 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.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply