• 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
create subimage from NSBitmapImageRep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

create subimage from NSBitmapImageRep


  • Subject: create subimage from NSBitmapImageRep
  • From: email@hidden
  • Date: Fri, 10 Aug 2007 23:32:57 +0200

Hello

I am a bit lost here...

So from  NSBitmapImageRep I want to get a sub image.

The code here is what I came up with. Please there must be a better concept?

Thank you

+ (NSBitmapImageRep *) subImage:(NSBitmapImageRep *)image rect: (NSRect)rect {
NSImage *sourceImage = [[NSImage alloc] initWithSize:[image size]];

[sourceImage lockFocus];
[image drawInRect:NSMakeRect(0,0, [image pixelsWide], [image pixelsHigh])];
[sourceImage unlockFocus];

NSRect targetRect = NSMakeRect(0, 0, rect.size.width, rect.size.height);
NSImage *cropedImage = [[NSImage alloc] initWithSize: targetRect.size];

[cropedImage lockFocus];
[[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationNone]; // no interpolation ?

[sourceImage drawInRect:targetRect fromRect:rect operation:NSCompositeCopy fraction:1.0];
NSBitmapImageRep *cropedRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(0, 0, rect.size.width, rect.size.height)];


	[cropedImage unlockFocus];
	return cropedRep;
}
_______________________________________________

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


  • Follow-Ups:
    • Re: create subimage from NSBitmapImageRep
      • From: Uli Kusterer <email@hidden>
  • Prev by Date: Re: User Shutdown or Logout
  • Next by Date: Re: pointer assignment inherently atomic ?
  • Previous by thread: Re: Overlay view drawing woes
  • Next by thread: Re: create subimage from NSBitmapImageRep
  • Index(es):
    • Date
    • Thread