ios - Compressing an NSKeyedArchiver file that included UIImageView with loaded image -


i have view uiimageview. loaded either jpg or png image format. says jpg image version has data size of 100k. used nskeyedarchiver save view file. size of file getting 3mb. if used png version of image, archived file still around 3mb.

i used zlib compress archived file. not seem have effect.

anything can close as possible 100k area?

btw: if used uiwebview load image, jpg version of image archived file's close original jpg's.

edit: matt's answer gave me idea, ended doing:

note: arleady used subclass of uiimageview

  1. create ivar hold nsdata image
  2. in encodewithcoder before calling [super encodewithcoder...], set self.image = nil; , set self.image image data using saved nsdata in 1.
  3. make sure encode nsdata ivar in 1.

in initwithcoder, using nsdata ivar restore image.

you don't need keyed archiver this.

if image came inside app, you've got image file, there's nothing save; archive image's name.

if image came from, say, internet, need here save original image in file (and, again, possibly archive path file, can recover later). had jpg image 100k @ point, why not capture that, @ time when have it? if arrived nsdata, well, there's data. if not, can turn jpeg data uiimagejpegrepresentation. either way, nsdata can saved directly file.

the most flexible , powerful way save (and later read) image data imageio framework, though.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -