NO

Author Topic: Icon Editor  (Read 5860 times)

nancy

  • Guest
Icon Editor
« on: April 24, 2012, 03:11:15 pm »
Hallo,

in pelles icon editor i can only use a very limited number of colors. So I often design my icons with other tools and try them to import later. But then I have trouble with transparent colors. How are you all create your icons? Can you give me some hints?

CommonTater

  • Guest
Re: Icon Editor
« Reply #1 on: April 25, 2012, 12:54:31 am »
Hallo,

in pelles icon editor i can only use a very limited number of colors. So I often design my icons with other tools and try them to import later. But then I have trouble with transparent colors. How are you all create your icons? Can you give me some hints?


Unless I'm making a very "quick and dirty" icon (eg. for a toolbar) I use an external editor called IcoFX which does a much better job with Vista styled icons.

To incorporate the icon into the program's resources I use the "Import" function from the right click menu in the resource editor.  Open your .rc file by double clicking it... on the top line right click and select "Import" then select your Icon in the file selection dialog.  The icon is then added to the RC as an external file which is linked in at build time.

nancy

  • Guest
Re: Icon Editor
« Reply #2 on: April 25, 2012, 06:09:30 pm »
Hallo CommonTater,

thank you for your tip.

I have downloaded IcoFX and made a little test icon. The background is transparent.
If I import to Pelles C the transparency is gone (preview on the left side). What have I done wrong?

nancy

CommonTater

  • Guest
Re: Icon Editor
« Reply #3 on: April 25, 2012, 06:18:30 pm »
Hallo CommonTater,

thank you for your tip.

I have downloaded IcoFX and made a little test icon. The background is transparent.
If I import to Pelles C the transparency is gone (preview on the left side). What have I done wrong?

nancy

It is gone when displayed for your program... or just in Pelles Icon editor?
It also depends how you are going to display the icon... If it's your program icon, leave it alone.  If it's to display as a bitmap in your program's windows you may need to use LoadImage() instead of LoadIcon() to get the transparency.

Also note that for 256 colour icons, the top left pixel is usually considered the "prime dot" and is used as the transparency colour, so you may have to load the icon into Pelles editor and flood fill the background with an actual colour... When I loaded it here, the background was dark grey... Flooding it with white allowed it to be seen as transparent in LoadImage().
 
 Also, I'm attaching a copy of one my icons you can open in IcoFX and have a look at... This is just a program icon, so the transparency displays nicely on the desktop. 
 
The second attachment is a button bar image used for toolbars... this was created directly in Pelles IDE.
 
 
 

 
 
« Last Edit: April 25, 2012, 06:31:42 pm by CommonTater »

nancy

  • Guest
Re: Icon Editor
« Reply #4 on: April 25, 2012, 10:56:33 pm »
It is gone when displayed for your program... or just in Pelles Icon editor?
In IcoFX I decided to make the lower left pixel (which was white) as transparent color. And at the IcoFX preview it looks good.
After my import to pelles icon editor the transparency was gone (there is a preview at the left side in Pelles icon editor). And the former white was dark grey.

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 580
    • Homepage
Re: Icon Editor
« Reply #5 on: April 26, 2012, 12:11:16 am »
The icon editor of the IDE doesn't support transparency, so don't open the icon with it and change it.

As Tater told you, just include the icon in the resource file and edit it with IcoFx, which will keep transparency and alpha layer.
---
Stefan

Proud member of the UltraDefrag Development Team

CommonTater

  • Guest
Re: Icon Editor
« Reply #6 on: April 26, 2012, 10:01:10 am »
In IcoFX I decided to make the lower left pixel (which was white) as transparent color. And at the IcoFX preview it looks good.

You don't have that choice.  Windows *always* uses the upper left pixel at 0, 0 for it's transparency colour.  That is, if you are using LoadImage() and that top left pixel is red, anything that is red in your icon becomes transparent.  (and now you know why that god awful moss coloured background in the editor... for transparency.)





nancy

  • Guest
Re: Icon Editor
« Reply #7 on: April 26, 2012, 08:19:37 pm »
But both the upper and the lower left pixels are white.
I don't understand that.

CommonTater

  • Guest
Re: Icon Editor
« Reply #8 on: April 26, 2012, 09:36:12 pm »
But both the upper and the lower left pixels are white.
I don't understand that.

Sorry for the repeated edits... had some kind of glitch when saving...
 
Ok, the thing is that a 256 colour image, which is using an 8 bit pallette does not support alpha channel transparency.  That requires a 32 bit pallette.  So to compensate Windows uses whatever it finds in that upper left corner as the "transparency colour" for the entire image.  If that spot is red, anything red in the image is not displayed so the background shows through.  Thus, if you want a transparent background you need to make the entire background, including that hot spot, the same colour.
 
IcoFx is a pretty sophisticated editor and most likely what it did was to allow you to edit with transparency but when it saved the icon as 8bits it decided a unique colour for the background so that windows could pick it up as the transparency colour.
 
Pelles Editor being a bit more honest, did the right thing and showed you the actual background colour...
 
Take a look at my button bar icons... notice how the entire background is a medium gray colour... including the 0,0 pixel.  When this is loaded into windows the result is that it sees the magic pixel and all that gray background is not displayed... The image background becomes transparent.  The same would have happened with your icon if the 0,0 pixel was the same colour as the rest of the background.
 
Here's an example of how to load a 256 bit image for transparency...
 
Code: [Select]
    if (Setting.Netbook)
      { bs = 32;
        is = 24;
        himu = ImageList_LoadImage(PgmInst,L"BIGBTN1",is,0,RGB(255,255,255),
                        IMAGE_BITMAP,LR_CREATEDIBSECTION | LR_LOADTRANSPARENT);
        himl = ImageList_LoadImage(PgmInst,L"BIGBTN2",is,0,RGB(255,255,255),
                        IMAGE_BITMAP,LR_CREATEDIBSECTION | LR_LOADTRANSPARENT); }

In your code you would subistitute IMAGE_ICON and your icon's name in the program's resources.
 
Pelles editor doesn't display the transparency... it's up to you to predictively prepare your images for proper display.  We are programmers, afterall :D
 
And here's the result...
 
« Last Edit: April 26, 2012, 09:52:59 pm by CommonTater »

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2181
    • http://www.smorgasbordet.com
Re: Icon Editor
« Reply #9 on: May 15, 2012, 06:14:28 pm »
Ummm.... I don't really get it...

The default colors are always non-transparent (alpha = 255), but if you work on a icon format with an alpha channel you can change the transparency for each color in the toolbox (just double-click on a color, then adjust the alpha level). There are buttons at the bottom of the toolbox for opening and saving a palette, if you do this often and want to keep the changes. It works for me at least...
/Pelle

CommonTater

  • Guest
Re: Icon Editor
« Reply #10 on: May 15, 2012, 06:25:35 pm »
Ahh... this was a 255 colour icon she'd created, Pelle... no alpha channel.