Real Software Forums
http://forums.realsoftware.com/

Drawing disabled icon
http://forums.realsoftware.com/viewtopic.php?f=21&t=44836
Page 1 of 1

Author:  shaosean [ Thu Jul 26, 2012 1:12 am ]
Post subject:  Drawing disabled icon

I know there is code kicking around for drawing an icon in a disabled state using the old mask part of a picture object, but here is what I am using with the new alpha channel feature..

this code is taken from the "2011r4 Alpha Channel Support.txt" file included with the IDE and will convert an old picture object to a new picture object with alpha channel
Function ModernizePicture(input as Picture) as Picture
if input.hasAlphaChannel then return input

dim result as new Picture( input.width, input.height )
result.graphics.drawPicture( input, 0, 0 )
return result
End Function


this code will draw the picture with 50% transparency giving it a disabled (dimmed) look..
Function GetDisabledImage(pImage As Picture) As Picture
if (pImage <> NIL) then
DIM tPicture As NEW Picture(pImage.Width, pImage.Height)
tPicture.Graphics.Transparency = 50.0
tPicture.Graphics.DrawPicture ModernizePicture(pImage), 0, 0, pImage.Width, pImage.Height
Return tPicture
end if
End Function


I am sure many others have already figured this out, but I was unable to find any sample code with the new alpha channel feature, so thought I would share and hopefully save someone a few minutes (or hours)

Author:  Markus Winter [ Thu Jul 26, 2012 5:51 am ]
Post subject:  Re: Drawing disabled icon

Very nice.

Note that this is Cocoa only as the alpha channel is not supported on Carbon.

Author:  DaveS [ Thu Jul 26, 2012 11:56 am ]
Post subject:  Re: Drawing disabled icon

I don;t know about Alpha support for DRAWPICTURE in CARBON

but it sure works for the COLOR object

g.forecolor=rgb(255,0,0,128)
g.drawline 0,0,100,100


will draw a red line at 50% transparency.... IN CARBON (r2011r3+)

I know... I'm doing it... results look great

Author:  Markus Winter [ Thu Jul 26, 2012 12:11 pm ]
Post subject:  Re: Drawing disabled icon

From the LR:

"Beginning with version 2011r4, Picture objects support alpha channels (transparency) directly, without the need for a mask.
Pictures with alpha channels are supported on Cocoa, Windows (with GDI+ enabled), Linux, console applications, and Web Edition. On platforms without support for alpha channels, a PlatformNotSupported exception is raised when trying to create the Picture."

So his code will fail in Carbon with a PlatformNotSupported exception

Author:  DaveS [ Thu Jul 26, 2012 12:24 pm ]
Post subject:  Re: Drawing disabled icon

Markus... I was not arguing or contradicting you... I was just saying that Alpha Channel for DRAWLINE does work in Carbon via the alphachannel parameter in the COLOR object.

Author:  Markus Winter [ Thu Jul 26, 2012 12:44 pm ]
Post subject:  Re: Drawing disabled icon

And I was just clarifying that my comment referred to his use of the picture object :wink:

Author:  shaosean [ Thu Jul 26, 2012 8:27 pm ]
Post subject:  Re: Drawing disabled icon

Markus Winter wrote:
Note that this is Cocoa only as the alpha channel is not supported on Carbon.


Cocoa, Win32 with GDI+ and Linux should all work with this.. There is tons of code on here that does it for Carbon..

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/