• 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: NSImage opacity or contrast (brightness)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage opacity or contrast (brightness)


  • Subject: Re: NSImage opacity or contrast (brightness)
  • From: Jack Nutting <email@hidden>
  • Date: Sat, 20 Aug 2005 02:49:27 +0200

On 8/19/05, Michael Marmarou <email@hidden> wrote:
> I have an image I am drawing in an NSRect, but I need it to be much
> lighter (like turning the opactiy down) because it's a background.
> The image file cannot be modified.  I see some sample code on the web
> for icons, but it doesn't seem to be working for my NSImage.   Also, I
> see there is a dissolveToPoint method which is used, but again I
> cannot get it to work.
>
> - (void)drawBackground:(NSRect)rect
> {
> NSImage *image = [NSImage imageNamed:@"image"];
> .......
>
> [image drawInRect...];
> }
>
> I need that ....... to ligthen my image, or lower opacity, or whatever
> gets that effect.

Actually, forget about the spot where you wrote ...... and instead,
after copying the image with [image drawInRect...], you can
"whitewash" it with something like this:

        [[NSColor colorWithCalibratedWhite:0.74 alpha:0.5] set];
        NSRectFillUsingOperation([self bounds],NSCompositeSourceOver);

Modify the white value to specify the target color (0.0 is black, 1.0
is white) and the alpha value to specify how "thick" you're laying it
on (0.0 will have no effect, 1.0 will replace your image with the
target color completely).

--
// jack
// http://www.nuthole.com
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSImage opacity or contrast (brightness) (From: Michael Marmarou <email@hidden>)

  • Prev by Date: Re: Reporting errors from key-value-coding accessors
  • Next by Date: Context Menu Plugin sample code
  • Previous by thread: NSImage opacity or contrast (brightness)
  • Next by thread: (id) sender
  • Index(es):
    • Date
    • Thread