• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSImage rendering upside down
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSImage rendering upside down


  • Subject: NSImage rendering upside down
  • From: Eric Cole <email@hidden>
  • Date: Tue, 29 Apr 2003 08:12:21 -0700

Ultimately, I am trying to remove the shadow from the image displayed in a status item. In doing so, it looks like the image needs to be drawn directly, so I have added a category to override drawInteriorWithFrame:inView: and draw the image.

Below is the source. The call to drawInRect:fromRect:operation:fraction: draws the image upside down.

Is there a better way to remove the shadow from an NSButtonCell drawing an image in a status item? If not, why is the image flipping and how is it turned off?

Thanks
Eric

@interface NSStatusBarButtonCell (Otsec)

- (void)drawInteriorWithFrame:(NSRect)inRect inView:(NSView *)inView;

@end

@implementation NSStatusBarButtonCell (Otsec)

- (void)drawInteriorWithFrame:(NSRect)inRect inView:(NSView *)inView {
NSImage *image = [(NSButtonCell *)self image];

NSRect from = NSZeroRect;
NSRect draw = inRect;

NSCompositingOperation mode = NSCompositeSourceOut;

if ( [self isHighlighted] ) {
image = [(NSButtonCell *)self alternateImage];
mode = NSCompositeSourceOver;
}

from.size = [image size];

if ( draw.size.width > from.size.width ) {
draw.origin.x += ( draw.size.width - from.size.width ) / 2.0;
}

if ( draw.size.height > from.size.height ) {
draw.origin.y += ( draw.size.height - from.size.height ) / 2.0;
}

[image drawInRect:draw fromRect:from operation:mode fraction:1.0];
}

@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSImage rendering upside down
      • From: email@hidden
  • Prev by Date: CPU load, time running ...
  • Next by Date: Unknown heart beat exception...
  • Previous by thread: Re: CPU load, time running ...
  • Next by thread: Re: NSImage rendering upside down
  • Index(es):
    • Date
    • Thread