• 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: affine transformation of bitmap images
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: affine transformation of bitmap images


  • Subject: Re: affine transformation of bitmap images
  • From: "Sean McBride" <email@hidden>
  • Date: Fri, 25 Feb 2005 11:02:36 -0500
  • Organization: Rogue Research

On 2005-02-24 16:29, Frank Midgley said:

>> Again, I have an NSBitmapImageRep and an NSAffineTransform, and I want
>> an
>> NSBitmapImageRep of the post-transformed image.
>
>When you create the NSImage also create an NSBitmapImageRep with the
>desired settings and add it to the image.  Then call
>-lockFocusOnRepresentation: instead of calling -lockFocus.

That seems to also result in an NSCachedImageRep, surprisingly!  My code
is as follows, is this what you meant?

// this is the starting image rep
NSBitmapImageRep*	origImgRep = [theSP imageRep];
NSSize				imgSize = [origImgRep size];

NSImage*			newImg = [[NSImage alloc] initWithSize:imgSize];
NSBitmapImageRep*	freshImageRep = [[NSBitmapImageRep alloc]
 initWithBitmapDataPlanes:NULL
	pixelsWide:imgSize.width
	pixelsHigh:imgSize.height
	bitsPerSample:[origImgRep bitsPerSample]
	samplesPerPixel:[origImgRep samplesPerPixel]
	hasAlpha:[origImgRep hasAlpha]
	isPlanar:[origImgRep isPlanar]
	colorSpaceName:[origImgRep colorSpaceName]
	bytesPerRow:[origImgRep bytesPerRow]
	bitsPerPixel:[origImgRep bitsPerPixel]];
[newImg addRepresentation:freshImageRep];
[newImg setCacheMode:NSImageCacheNever];

[newImg lockFocusOnRepresentation:freshImageRep];
[theTransform concat];
NSRect	wholeImageRect = NSMakeRect(
 0.0f, 0.0f, imgSize.width, imgSize.height);
[origImgRep drawInRect:wholeImageRect];
[newImg unlockFocus];

NSArray*			reps = [newImg representations];
assert ([reps count] == 1);
NSBitmapImageRep*	newImgRep = [reps objectAtIndex:0];
NSLog (@"%@", [newImgRep class]);

The logs shown there is only 1 rep, and its an NSCachedImageRep.

Thanks!

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


 _______________________________________________
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: 
 >Re: affine transformation of bitmap images (From: Frank Midgley <email@hidden>)

  • Prev by Date: Re: Maybe OT: Xcode, strange behaviour
  • Next by Date: Re: How to know a file is writeable?
  • Previous by thread: Re: affine transformation of bitmap images
  • Next by thread: Re: affine transformation of bitmap images
  • Index(es):
    • Date
    • Thread