Re: NSImage information
Re: NSImage information
- Subject: Re: NSImage information
- From: Ian was here <email@hidden>
- Date: Sat, 22 Sep 2007 10:30:13 -0700 (PDT)
A factor of 1.0 gives you maximum compression, while
0.0 gives you maximum quality. This is an NSImage
category I wrote.
- (NSData
*)JPEGDataWithCompressionFactor:(float)factor
{
[self lockFocus];
NSBitmapImageRep *bmRep = [[NSBitmapImageRep alloc]
initWithFocusedViewRect:[self bounds]];
[self unlockFocus];
NSNumber *factorNumber = [NSNumber
numberWithFloat:factor];
NSDictionary *props = [NSDictionary
dictionaryWithObject:factorNumber
forKey:NSImageCompressionFactor];
NSData *jpgData = [bmRep
representationUsingType:NSJPEGFileType
properties:props];
[bmRep release];
return jpgData;
}
Hope this helps.
--- Development <email@hidden> wrote:
> Thank you very much for your reply... Hmmm, I
> searched NSImageRep and
> NSImage and did not think to search the bitmap I
> just assumed it was
> a reference to the windows bmp file type. I see very
> clearly now that
> it would return the data I want based on what I tell
> it.
>
> The other question I had that I do not think my
> email clearly stated
> looking back at it, was the quality issue for the
> jpeg. Now as I am
> looking at the bitimagerep there is a key for
> compression factor. My
> intuition tells me that if I set this number to 1.0
> I will get the
> best quality image and if I set it to 0.0 I'll get a
> very small very
> fast very ugly image. Is this correct or do I still
> need to keep
> reading?
>
>
> Thanks again
> April.
> _______________________________________________
>
> 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
>
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/
_______________________________________________
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