• 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
Re: Darken image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Darken image


  • Subject: Re: Darken image
  • From: Andreas Monitzer <email@hidden>
  • Date: Fri, 20 Jul 2001 02:09:30 +0200

On Friday, July 20, 2001, at 12:44 , Tom Waters wrote:

well, i just wrote a tiny test harness for it, and it works as advertised.
..

this is a simple nsview subclass that lets you drag around the application icon... it shows the darkened one while you are dragging...

let me know if it doesn't work for you.

Yes, your example works fine. However, when I try to insert it into my code, it goes crazy.

Here's what I converted it to:

// theRect = the NSRect I got via drawRect
// imageRect = the NSRect I should draw into (part of theRect)
if (selected) {
NSSize iconSize = [icon size];
NSRect iconRect = {NSZeroPoint, iconSize};
NSImage *im = [[icon copyWithZone:[self zone]] autorelease];

[im lockFocus];
[im unlockFocus];
icon = im;
}

[icon drawInRect: imageRect fromRect: theRect
operation: NSCompositeSourceOver fraction: 1.0];

When selected==NO, everything is fine. But when it's YES, the icon is scaled up, scaled down, changes DPI or does something else (depends on the icon). When I remove lockFocus and unlockFocus, it's fine again, but I can'
t draw into it!

When using this code...

if (selected) {
NSSize iconSize = [icon size];
NSRect iconRect = {NSZeroPoint, iconSize};
NSImage *im = [[[NSImage alloc] initWithSize: iconSize] autorelease];

[im lockFocus];
// copy the icon into the new one
[icon drawInRect: iconRect fromRect: theRect
operation: NSCompositeCopy fraction: 1.0];

[im unlockFocus];
icon = im;
}

[icon drawInRect: imageRect fromRect: theRect
operation: NSCompositeSourceOver fraction: 1.0];

...all icons are scaled down (non-proportional).


What the hell is going on here?

andy
--
Description forthcoming.


  • Follow-Ups:
    • Re: Darken image
      • From: Tom Waters <email@hidden>
References: 
 >Re: Darken image (From: Tom Waters <email@hidden>)

  • Prev by Date: Where do I find detailed documentation on DO?
  • Next by Date: Re: Darken image
  • Previous by thread: Re: Darken image
  • Next by thread: Re: Darken image
  • Index(es):
    • Date
    • Thread