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

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

References: 
 >Re: NSImage information (From: Development <email@hidden>)

  • Prev by Date: Re: MySQL with Cocoa
  • Next by Date: Re: MySQL with Cocoa
  • Previous by thread: Re: NSImage information
  • Next by thread: UI Effects
  • Index(es):
    • Date
    • Thread