• 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: how to cache images
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to cache images


  • Subject: Re: how to cache images
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Sun, 09 Jun 2013 12:23:51 +0700

On 9 Jun 2013, at 08:57, Kyle Sluder <email@hidden> wrote:

> On Jun 8, 2013, at 5:39 PM, "Gerriet M. Denkmann" <email@hidden> wrote:
>
>>
>> On 9 Jun 2013, at 06:23, Jens Alfke <email@hidden> wrote:
>>
>>>
>>> On Jun 8, 2013, at 12:24 PM, Ken Thomases <email@hidden> wrote:
>>>
>>>> I haven't done the experiment, but I don't believe this is necessarily true.  NSBitmapImageRep is documented (in the Snow Leopard release notes) as keeping the original image data and not re-encoding or exploding file sizes on being saved.
>>>
>>> I did not know this — guess I haven’t been reading the release notes closely enough.
>>
>>   url = some/picture.gif
>>   NSDataReadingOptions mask = 0;    //    NSDataReadingUncached
>>   NSData *data = [ NSData dataWithContentsOfURL: url options: mask error: &outError ];
>> got 19420 bytes
>>
>>   NSImage *image = [ [ NSImage alloc ] initWithContentsOfURL: url ];
>>   BOOL ok = [ NSArchiver archiveRootObject: image toFile: @"/tmp/anImage" ];
>> got 307559 bytes (NSKeyedArchiver adds another half  kB)
>>
>> This 16-fold increase of data is - regardless of image quality - not acceptable for my purposes.
>
> This is why you don't use NSArchiver for data blobs: it writes them out as Base64-encoded plist strings.

My gif-image has only one representation:
 "NSBitmapImageRep 0x109cdf610 Size={320, 320} ColorSpace=Device RGB colorspace BPS=8 BPP=32 Pixels=320x320 Alpha=NO Planar=NO Format=0 CurrentBacking=<CGImageRef: 0x10c878eb0> CGImageSource=0x116e02580"

And the archive contains (among a few other things, like an NSColor) an NSBitmapImageRep, which contains a characterArray of 307394 chars = 3 * 320 * 320 + 194.

This is the archiver format, not the property list format.

So it seems that in initialising my image with gif-data, the original data was somehow lost.


And when I do:
	NSArray *imageReps = [ self.imageView.image representations];
	NSData *gifData = [ NSBitmapImageRep representationOfImageRepsInArray: imageReps usingType: NSGIFFileType properties: nil ];

it gets smaller indeed. From 19k to about 3k -- But: while the original was an animated gif,
the new gifData is no longer animated. Not very useful to me.

I looked at the properties parameter, but did not see anything relating to animation.


Kind regards,

Gerriet.



_______________________________________________

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: how to cache images
      • From: Kyle Sluder <email@hidden>
References: 
 >how to cache images (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: how to cache images (From: Ken Thomases <email@hidden>)
 >Re: how to cache images (From: Jens Alfke <email@hidden>)
 >Re: how to cache images (From: Ken Thomases <email@hidden>)
 >Re: how to cache images (From: Jens Alfke <email@hidden>)
 >Re: how to cache images (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: how to cache images (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: how to cache images
  • Next by Date: Re: how to cache images
  • Previous by thread: Re: how to cache images
  • Next by thread: Re: how to cache images
  • Index(es):
    • Date
    • Thread