Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 22, 2011, 09:59 PM   #1
hiddenpremise
macrumors regular
 
Join Date: Jul 2008
Location: Somewhere between my imagination and reality
reading image from plist with Jpeg photo data

Hi, I've got a plist file with jpeg photo data in it. I need to get that photo out. I can read the plist file into an NSDictionary and can access the object at the key "jpegphoto". The problem is that the object returned is an NSCFArray that I have no idea how to work with. I can print it and I see a nice stream of octets come out, but that's all I know how to do. How do I get this NSCFArray into NSData or a byte array?

The CFArray when passed to NSLog like so
Code:
NSLog(@"%@", [data_dictionary objectForKey:@"jpegphoto"]);
Spits out hundreds of line similar to
Code:
5ed15ee6 df44b2ff 00899699 0dd23b58 dccdcadc 6c8d04e1 8b3e1940 af76953e 7c0e1b56
I know that it is a CFArray b/c I did
Code:
NSLog(@"%@", NSStringFromClass([[data_dictionary objectForKey:@"jpegphoto"] class]));
And got back
Code:
NSCFArray
Thanks
__________________
MBP i7 | iPhone 4 | iPad

Last edited by hiddenpremise; Apr 22, 2011 at 10:08 PM. Reason: minor typo
hiddenpremise is offline   0 Reply With Quote
Old Apr 22, 2011, 11:43 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Where is this plist coming from? If the "jpegphoto" was an NSData that'd be pretty obvious how to load it, but since it's an array it's unclear what the array is holding.

Can you loop through the array and print out the class name of each of its objects?
kainjow is offline   0 Reply With Quote
Old Apr 22, 2011, 11:49 PM   #3
Sydde
macrumors 68000
 
Sydde's Avatar
 
Join Date: Aug 2009
From what you are showing, it looks like an array of either NSNumbers or NSStrings. You might try concatenating the values in the array together to form a block of data that NSImage would be able to convert.

If it is NSNumbers, you should be able to just walk a pointer through a data block for each number. If it is hex-encoded strings, you would have to use a NSScanner to convert them to numbers (-scanHexInt:).
__________________
You got to be a spirit. You can't be no ghost.
Sydde is offline   0 Reply With Quote
Old Apr 23, 2011, 11:36 AM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by hiddenpremise View Post
Spits out hundreds of line similar to
Code:
5ed15ee6 df44b2ff 00899699 0dd23b58 dccdcadc 6c8d04e1 8b3e1940 af76953e 7c0e1b56
If that's the start of the data, I have no idea what it represents. It's not a JFIF (JPEG File Interchange Format, aka JPEG file).
http://en.wikipedia.org/wiki/JPEG_Fi...rchange_Format

If that isn't the start of the data, then post the starting line of data.

How do you know it's JPEG data? If you told us where the data came from, we might have better suggestions.

Last edited by chown33; Apr 23, 2011 at 11:54 AM.
chown33 is offline   0 Reply With Quote
Old Apr 24, 2011, 12:44 PM   #5
hiddenpremise
Thread Starter
macrumors regular
 
Join Date: Jul 2008
Location: Somewhere between my imagination and reality
I know it is jpeg data because the key in the plist is called "jpegphoto". And what I posted is just the beginning. I shortened it b/c that actual data is very long. Thanks!
__________________
MBP i7 | iPhone 4 | iPad
hiddenpremise is offline   0 Reply With Quote
Old Apr 24, 2011, 02:18 PM   #6
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
Quote:
Originally Posted by hiddenpremise View Post
I know it is jpeg data because the key in the plist is called "jpegphoto". And what I posted is just the beginning. I shortened it b/c that actual data is very long. Thanks!
It could still be JPEG data, but without the JFIF/EXIF headers or with the headers later in the stream. If so you might have trouble interpreting it without necessarily knowing the image's dimensions, etc...

Do you find 0xFFE0????4A46 anywhere in the stream?

B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
picking datas from plist file. sakthivadivel.a iPhone/iPad Programming 3 Nov 7, 2011 10:54 PM
How do I stop my iPhone from syncing with every photo on my iMac? drgrafix iPhone Tips, Help and Troubleshooting 1 May 11, 2011 09:34 AM
Reading Date from database in Ipad ashwinr87 iPhone/iPad Programming 0 Apr 25, 2011 11:11 AM
PhotosMail 1.0 for iOS - Integrated Tool for Sending Photos by Email application iPhone and iPod touch Apps 1 Jan 25, 2011 02:58 AM
Back from NYC with some photos! Thanks for the advice! cutsman Digital Photography 11 May 29, 2009 08:00 AM


All times are GMT -5. The time now is 09:06 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC