• 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
Scale and NSCompositePlusDarker
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scale and NSCompositePlusDarker


  • Subject: Scale and NSCompositePlusDarker
  • From: Lorenzo <email@hidden>
  • Date: Wed, 21 Jul 2004 20:56:06 +0200

Hi,
I would like to scale an NSImage and make it darker. I made the following.
The original image has been scaled properly, but the brigthness is the same
(not good). And I got the result in the original image itself and not as I
expected in the darkImage. Also the "Dark" image contains a gray square...
What did I make wrong?


- (void)ResizeDarker:(NSImage*)anImage oldSize:(NSSize)oldSize
newSize:(NSSize)newSize
{
NSImage *darkImage = [[NSImage alloc] initWithSize:newSize];

NSRect sourceRect = NSMakeRect(0, 0, oldSize.width, oldSize.height);
NSRect destRect = NSMakeRect(0, 0, newSize.width, newSize.height);

[anImage setScalesWhenResized:YES];
[anImage setSize:newSize];
[darkImage lockFocus];
[anImage drawInRect:destRect fromRect:sourceRect
operation:NSCompositePlusDarker fraction:0.5];
[darkImage unlockFocus];

[[anImage TIFFRepresentation] writeToFile:@"/Original.tiff"
atomically:YES];

// This image now contains a gray square. Strange. Why?
[[darkImage TIFFRepresentation] writeToFile:@"/Dark.tiff"
atomically:YES];
[darkImage release];
}


Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
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.


  • Prev by Date: Re: Problems with NSTextField and attributed strings
  • Next by Date: Re: Links in NSTextView
  • Previous by thread: Re: Using NSStream fails
  • Next by thread: Cocoa<->Carbon troubles
  • Index(es):
    • Date
    • Thread