Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Oct 19, 2017 5:01 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Drawing disabled icon
PostPosted: Thu Jul 26, 2012 1:12 am 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
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)


Top
 Profile  
Reply with quote  
 Post subject: Re: Drawing disabled icon
PostPosted: Thu Jul 26, 2012 5:51 am 
Offline

Joined: Sun Feb 19, 2006 4:00 pm
Posts: 1282
Location: Heidelberg, Germany
Very nice.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Drawing disabled icon
PostPosted: Thu Jul 26, 2012 11:56 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
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

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Drawing disabled icon
PostPosted: Thu Jul 26, 2012 12:11 pm 
Offline

Joined: Sun Feb 19, 2006 4:00 pm
Posts: 1282
Location: Heidelberg, Germany
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Drawing disabled icon
PostPosted: Thu Jul 26, 2012 12:24 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
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.

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Drawing disabled icon
PostPosted: Thu Jul 26, 2012 12:44 pm 
Offline

Joined: Sun Feb 19, 2006 4:00 pm
Posts: 1282
Location: Heidelberg, Germany
And I was just clarifying that my comment referred to his use of the picture object :wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: Drawing disabled icon
PostPosted: Thu Jul 26, 2012 8:27 pm 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
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..


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group