Re: Transparent image
Re: Transparent image
- Subject: Re: Transparent image
- From: Steve Christensen <email@hidden>
- Date: Tue, 10 Feb 2009 07:19:30 -0800
I understand that IKImageView respects the alpha channel of the
image. My suggestions were directed at seeing if it was possible to
make the view's background transparent. From some of the other
replies it sounds like that's not possible, or at least, not very
easy to do.
Depending on what you're trying to do overall, you could also create
your own custom view that has a transparent background and apply a
NSAffineTransform before drawing the image to cause it to rotate,
scale, flip, whatever...
On Feb 10, 2009, at 12:44 AM, Christian Graus wrote:
OK - I've overridden isOpaque and I am returning NO. This method
is being called, so I am sure I've done that bit right. In the
same code, I added code to set the background color to clearColor
( net result is that the background is black ) or used the code you
gave me earlier ( net result is, the background is white ). It
seems there is no way to get the control to draw itself
transparently, even though it plainly knows how to draw with
respect to the alpha in the png, turning on the grid option makes
that clear. Is there a method I can override, and then take a
screen shot of my background, and make that the image behind the
image drawn on the control ? I am adding an IKImageView derived
class onto my main window in the XIB ( I've actually tried just
adding it in code, too ) and I need this class for the paint tools
it gives me access to. So, if the control does not support being
transparent, I need to find a way to fake it.
Thanks
Christian
On Tue, Feb 10, 2009 at 11:25 AM, Steve Christensen
<email@hidden> wrote:
Sorry, I misread your original posting. You're trying to make the
view transparent, not the window. Based on what you're seeing when
you set the view's backgroundColor, it looks like the alpha
component is being ignored. I would guess that either the
IKImageView only supports an opaque background or you need to play
with it some more to get transparency to work. One way to find out
would be to subclass IKImageView and override NSView's isOpaque
method, returning NO.
Also, depending on what you're trying to do, you could always use
NSImageView since that does respect transparency, at least when
I've tried it with the non-bordered version.
On Feb 9, 2009, at 3:10 PM, Christian Graus wrote:
I'm sorry, I'm not sure that I'm following this.
Looking at it more closely, on the side I want this behaviour,
it's just an IKImageView derived class on top of a window. So, I
just need to make the IKImageView show the image, transparently.
I've tried setting the Opaque setting, but it doesn't appear to
have one. I've also tried setting the background color to what
you've shown here ( it gives me a white background ) or clearColor
( which gives me a black background ). Is there something I am
missing ?
Thanks for your help
Christian
On Tue, Feb 10, 2009 at 9:18 AM, Steve Christensen
<email@hidden> wrote:
Something similar to what you're asking was discussed on this list
last week. To get you started:
[window setOpaque:NO];
[window setBackgroundColor:[NSColor colorWithCalibratedWhite:1.0
alpha:0.5]];
On Feb 9, 2009, at 1:55 PM, Christian Graus wrote:
I have a window with an image showing on it. Above this I have a
window,
which contains an IKImageView derived class. The IKImageView has
a PNG in
it, which has a transparency layer. What I need to do, is to make
that
image appear above the image I have in my main window, that is,
the control
needs to be transparent, so that one picture appears above
another. I've
found a sample that sets the window alpha, but that fades the
whole window,
I just want to make the background transparent. I'd appreciate any
suggestions.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden