realbasic-nug
[Top] [All Lists]

Re: Windows Toolbar Icons Suck?

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Windows Toolbar Icons Suck?
From: Joe Strout <joe at inspiringapps dot com>
Date: Tue, 30 Oct 2007 15:26:25 -0600
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <CDE4A517-C618-4B0B-8269-B89BBEB13E40 at thezaz dot com>
On Oct 30, 2007, at 3:02 PM, Thom McGrath wrote:

> I just tried using the RB toolbar for the first time on Windows, and
> the icons it creates are horrible. I supply it with a proper alpha-
> channel picture, and the result gives me just the opposite: no alpha
> channel. Just transparent.

That's a Windows toolbar for you.

> Is there a workaround besides guessing the background color and
> drawing it in myself?

Here's the relevant bit from the notes I've been collecting on a  
"Best Practices" book for RB... though work has kept me so busy  
lately, I don't know if or when I'll get around to actually writing  
it...

Windows supports only 1-bit masking on a toolbar icon, so a  
beautifully antialiased icon for Mac or Linux will look horrible on  
Windows... UNLESS the icon is drawn onto a neutral background color.   
Use &cDEDED0 as the background color of the icon, and it'll look good  
on all platforms.

If your icons were made against another background color (most  
artists will use black), you can convert them with code like this  
(assuming the mask has the same file name but ending in "-Mask.bmp"):

   Dim srcp As Picture = f.OpenAsPicture
   if srcp is nil then
     Print "Unable to open " + f.Name
     return
   end if
   Dim maskName As String = Left( f.Name, f.Name.Len - 4 ) + "-Mask.bmp"
   Dim mask As Picture = f.Parent.Child( maskName ).OpenAsPicture
   if mask is nil then
     Print "Unable to open " + maskName
     return
   end if
   srcp.Mask.Graphics.DrawPicture mask, 0, 0
   Dim outp As New Picture( srcp.Width, srcp.Height, 32 )
   outp.Graphics.ForeColor = &cDEDED0
   outp.Graphics.FillRect 0, 0, srcp.Width, srcp.Height
   outp.Graphics.DrawPicture srcp, 0, 0

   Dim qtex As QTGraphicsExporter = GetQTGraphicsExporter( "BMPf" )
   qtex.OutputFileCreator = "GKON"
   if qtex.SavePicture( f, outp ) then
     Print "Saved picture to " + f.Name + "."
   else
     Print "Export failed."
   end if


--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com



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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>