Xojo Conferences
XDCMay2019MiamiUSA

Transparent Icons in ToolbarItems? (Real Studio getting started Mailinglist archive)

Back to the thread list
Previous thread: keeping tabs in a canvas
Next thread: RB version of LapLink


RB Database   -   tom.russell transport.alstom.com
  Transparent Icons in ToolbarItems?   -   Mark
   Re: Transparent Icons in ToolbarItems?   -   Charles Yeomans
   Re: Transparent Icons in ToolbarItems?   -   Mark Cooke
    RE: Transparent Icons in ToolbarItems?   -   Dixon, Tom
     Re: Transparent Icons in ToolbarItems?   -   Mark Cooke
     Re: Transparent Icons in ToolbarItems?   -   Brad Rhine
    RE: Transparent Icons in ToolbarItems?   -   Dixon, Tom
   RE: Transparent Icons in ToolbarItems?   -   Emile Schwarz
   Re: Transparent Icons in ToolbarItems?   -   Mark Cooke
    Re: Transparent Icons in ToolbarItems?   -   Lars Jensen
   Re: Transparent Icons in ToolbarItems?   -   Emile Schwarz

Transparent Icons in ToolbarItems?
Date: 04.02.06 15:06 (Sat, 4 Feb 2006 14:06:04 +0000)
From: Mark
Hi,

I'm having major problems, trying to put a transparent png as the
Icon for a toolbar item,
for some reason it makes the background white (this also seems to
happen for a Canvas background as well)..

I've looked through the Language Reference and cannot see any option
there, I've also tried *.gif and *.psd's, but all have the same
effect. The only workaround I can see is to take a screen shot of the
app, then use the toolbar background colour as the background for my
icons.

Thanks

Mark
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Transparent Icons in ToolbarItems?
Date: 04.02.06 20:59 (Sat, 4 Feb 2006 14:59:04 -0500)
From: Charles Yeomans

On Feb 4, 2006, at 9:06 AM, Mark wrote:

> Hi,
>
> I'm having major problems, trying to put a transparent png as the Icon
> for a toolbar item,
> for some reason it makes the background white (this also seems to
> happen for a Canvas background as well)..
>
> I've looked through the Language Reference and cannot see any option
> there, I've also tried *.gif and *.psd's, but all have the same
> effect. The only workaround I can see is to take a screen shot of the
> app, then use the toolbar background colour as the background for my
> icons.

For MacOS X toolbar icons, I have found it simpler to use an .icns file
and set the icon using HIToolbarItemSetIconRef. I explain how to do so
in chapter 3 of my book on declares <http://www.declareSub.com/>.
MacOS X includes a utility, tiff2icns, that will convert TIFF images to
.icns files.

--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Transparent Icons in ToolbarItems?
Date: 05.02.06 10:06 (Sun, 5 Feb 2006 09:06:15 +0000)
From: Mark Cooke
Thanks everyone for the help, I decided to go with what I class as
the simplest option,
for this, in the end if was Toms answer.

I created a new image and gave it a pure white background, any pixels
in that image that I needed to be white;
I gave them a colour, just off white (so the human eye cannot even
see the difference, but RB does).
Saved this as a PNG; then I imported the picture 'MyImage' into the
project.

In the Open even on the Canvas, I simply added the following:

Dim p As Picture

p = New Picture(59,61,32) // Set the Width, Height and Colour Depth
p.Transparent = 1 // Set the background image to Transparent, the
background must be pure white.
p.Graphics.DrawPicture MyImage,0,0 // Draw the imported picture
'MyImage ' at the coordinates 0,0

// Assign the Image to the backdrop property of this Canvas.
Me.Backdrop = p

I hope this is the correct place to place this?

Mark
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

RE: Transparent Icons in ToolbarItems?
Date: 04.02.06 15:25 (Sat, 4 Feb 2006 08:25:36 -0600)
From: Dixon, Tom
The transparency in a .png is not automatically supported. I believe you
need to use the mask property of a picture to create a transparent
picture which means creating a mask image for the toolbar icon as well.

Dim p As Picture

p = New Picture(32,32,32)
p.Graphics.DrawPicture MyIcon,0,0
p.Mask.Graphics.DrawPicture MyIconMask,0,0

Then set the image property from the picture.

You would do the same thing to draw a transparent picture in a Canvas or
an icon in a BevelButton

Tom

> I'm having major problems, trying to put a transparent png as
> the Icon for a toolbar item, for some reason it makes the
> background white (this also seems to happen for a Canvas
> background as well)..
>
> I've looked through the Language Reference and cannot see any
> option there, I've also tried *.gif and *.psd's, but all have
> the same effect. The only workaround I can see is to take a
> screen shot of the app, then use the toolbar background
> colour as the background for my icons.
>
> Thanks
>
> Mark
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Transparent Icons in ToolbarItems?
Date: 04.02.06 15:59 (Sat, 4 Feb 2006 14:59:40 +0000)
From: Mark Cooke
Thanks for that, oh well I was hoping it was going to be a simple
property I have to set :(

Image creation is not my strong point, I can create an (what just
about passes for an Icon) and when I save it, it does have a
transparent background, so I take it thats the Transparency of the
icon sorted, so I would just have to deal with REALbaisic then?

Out of curiosity, does Realbasic support transparency in images
without adding Masks?

Thanks

Mark

On 4 Feb 2006, at 14:25, Dixon, Tom wrote:

> The transparency in a .png is not automatically supported. I
> believe you
> need to use the mask property of a picture to create a transparent
> picture which means creating a mask image for the toolbar icon as
> well.
>
> Dim p As Picture
>
> p = New Picture(32,32,32)
> p.Graphics.DrawPicture MyIcon,0,0
> p.Mask.Graphics.DrawPicture MyIconMask,0,0
>
> Then set the image property from the picture.
>
> You would do the same thing to draw a transparent picture in a
> Canvas or
> an icon in a BevelButton
>
> Tom
>
>> I'm having major problems, trying to put a transparent png as
>> the Icon for a toolbar item, for some reason it makes the
>> background white (this also seems to happen for a Canvas
>> background as well)..
>>
>> I've looked through the Language Reference and cannot see any
>> option there, I've also tried *.gif and *.psd's, but all have
>> the same effect. The only workaround I can see is to take a
>> screen shot of the app, then use the toolbar background
>> colour as the background for my icons.
>>
>> Thanks
>>
>> Mark
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Transparent Icons in ToolbarItems?
Date: 04.02.06 19:14 (Sat, 4 Feb 2006 13:14:14 -0500)
From: Brad Rhine
On Feb 4, 2006, at 9:59 AM, Mark Cooke wrote:

> Thanks for that, oh well I was hoping it was going to be a simple
> property I have to set :(
>
> Image creation is not my strong point, I can create an (what just
> about passes for an Icon) and when I save it, it does have a
> transparent background, so I take it thats the Transparency of the
> icon sorted, so I would just have to deal with REALbaisic then?
>
> Out of curiosity, does Realbasic support transparency in images
> without adding Masks?

Not directly. If you need a quick and dirty way to extract a mask
from a .png as a separate image, I have something that might work. I
wrote a little utility last month that reads the alpha channel from
a .png and saves it to another .png file. That way, you have the
original plus the new mask image to drop into RB. Gimme a shout off-
list if you'd like to try it out.

RE: Transparent Icons in ToolbarItems?
Date: 04.02.06 17:28 (Sat, 4 Feb 2006 10:28:50 -0600)
From: Dixon, Tom
Not to my knowledge at this time. I believe there have been feature
requests filed to support transparency natively in .png files. You can
search and add your vote for any you find.

> Out of curiosity, does Realbasic support transparency in
> images without adding Masks?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

RE: Transparent Icons in ToolbarItems?
Date: 05.02.06 10:49 (Sun, 05 Feb 2006 10:49:16 +0100)
From: Emile Schwarz
Hi All,

1. Answer to the original question
I already had that trouble and found a solution. Of course, I do not remember
what it was, but I will search right now.

<after the quest>
As far as I can tell, once I created a Mask, I get the desired behavior.

Explanation:

a. Load the icon from file
b. Create a mask for that Icon [every non white pixel (in the loaded Icon) is
set to black (in the Mask Icon)]
c. Use:

IconPict.Mask.Graphics.DrawPicture GeneratedMask,0,0

and you are done.

Nota: to create the Icon Mask, use two nested loops and a RGBSurface Instance to
read / write the Pixel.

You can find nearly all the code in the RBNUG thread called: "Why is this a Nil
Object"; I share 95% of the code you need there. You have to put some Dim and
the part that read the color in the original Icon and write the Black in the
Mask icon (so you need to create a mask picture and return it once it is done).

At last, there is a max width / height you have to respect in the original (thus
in the Mask) Icon. I do not remember, but 32 x 32 seems a good size.

Now, if everything goes well, you will be able to have only the Icon highlighted
when you press the mouse on it !

This is only for custom loaded Icons. The build-in Icons works already like
that. You have nothing special / fancy to do ;)


2. Answer to the below text
---------------------------

Did you read the pdf documentation ? Especially the Language Reference, Picture
Class ?

<quote>
Picture.Transparent Property
Syntax

Transparent as Integer

Controls the transparency of the white 'layer' of the picture.
0 - Not transparent.
1 - White is transparent.
</quote>

HTH,

Emile

<email address removed> wrote:
> Subject: RE: Transparent Icons in ToolbarItems?
> From: "Dixon, Tom" <<email address removed>>
> Date: Sat, 4 Feb 2006 10:28:50 -0600
>
> Not to my knowledge at this time. I believe there have been feature
> requests filed to support transparency natively in .png files. You can
> search and add your vote for any you find.
>
>>> Out of curiosity, does Realbasic support transparency in
>>> images without adding Masks?

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Transparent Icons in ToolbarItems?
Date: 05.02.06 19:10 (Sun, 5 Feb 2006 18:10:50 +0000)
From: Mark Cooke

On 5 Feb 2006, at 09:49, Emile Schwarz wrote:
>
> Did you read the pdf documentation ?

Yes, but so far not every page (YET), I've only been using RB for
around 3 days,
and still struggling to get to grips with some of the syntax and the
way it works compared to the
other languages that I have been using for the past 6 years.

> Especially the Language Reference, Picture Class ?

No!, but thanks to previous posts I have now realized that this is
the section I need to be concentrating on for this question;
I wrongly assumed that RB would handle transparency if the imported
image already had a transparency mask.

Mark

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Transparent Icons in ToolbarItems?
Date: 05.02.06 19:57 (Sun, 5 Feb 2006 10:57:10 -0800)
From: Lars Jensen
Frank Condello's excellent and free PNG Utilities plugin makes
transparency and masking easy:

http://developer.chaoticbox.com

Plugins are a maintenance and code sharing hassle, but I like PNGs, so
I put up with it for this one. Using it, I wrote up a PNG image/mask
splitter that will do a file or folder (recursively) at a time, saving
the images and masks to the desktop as separate PICT files. Let me
know if you want the code or app.

lj
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Transparent Icons in ToolbarItems?
Date: 07.02.06 08:15 (Tue, 07 Feb 2006 08:15:34 +0100)
From: Emile Schwarz


<email address removed> wrote:
> Subject: Re: Transparent Icons in ToolbarItems?
> From: Mark Cooke <<email address removed>>
> Date: Sun, 5 Feb 2006 18:10:50 +0000
>
> On 5 Feb 2006, at 09:49, Emile Schwarz wrote:
>
>>>
>>> Did you read the pdf documentation ?
>
> Yes, but so far not every page (YET), I've only been using RB for
> around 3 days,
> and still struggling to get to grips with some of the syntax and the
> way it works compared to the
> other languages that I have been using for the past 6 years.

Welcome!

>>> Especially the Language Reference, Picture Class ?
>
> No!, but thanks to previous posts I have now realized that this is
> the section I need to be concentrating on for this question;
> I wrongly assumed that RB would handle transparency if the imported
> image already had a transparency mask.
>
> M

Valid question. I forget that kind of case ;)

However, you can read the FolderItem Class (for File I/O)...

Regards,

Emile

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>