PDA

View Full Version : UIImage imageWithContentsOfFile with file outside the project




siliconKai
Dec 15, 2008, 07:04 AM
Hey guys,
i am trying to implement my own UIImagePicker, because i am not satisfied with the one of the SDK.
I want to know which file is selected.

I have created an UITableView in which I display the thumbnail *.thm-file and the image name. When a row is selected my ImagePicker is removed and a UIImageView is updated with the contents of the file selected.

Then the apllication crashes, the debugger returns the following:


2008-12-15 13:52:51.454 PENPicture[1731:20b] /User/Media/DCIM/100APPLE/IMG_0003.JPG
Program received signal: “EXC_BAD_ACCESS”.
gdb stack crawl at point of internal error:
[ 0 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (align_down+0x0) [0x1219b9]
[ 1 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (frame_register+0xc7) [0x127a23]
[ 2 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (frame_register_read+0x3c) [0x127b68]
[ 3 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (do_frame_register_read+0x1f) [0x127ba6]
[ 4 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (regcache_save+0xdf) [0x2c318]
[ 5 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (frame_save_as_regcache+0x4a) [0x12675f]
[ 6 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (frame_pop+0x25) [0x128bea]
[ 7 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (hand_function_call+0x10d1) [0x60846]
[ 8 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (call_function_by_hand+0x2f) [0x60a9e]
[ 9 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (allocate_space_in_inferior_malloc+0xc5) [0x39d66]
[ 10 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (value_array+0x180) [0x3f108]
[ 11 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (evaluate_subexp_standard+0x1187) [0x36634]
[ 12 ] /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin (evaluate_subexp_with_coercion+0x5d) [0x34e9b]
/SourceCache/gdb/gdb-961/src/gdb/frame.c:661: internal-error: frame_register: Assertion `frame != NULL && frame->next != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

The Debugger has exited with status 1.The Debugger has exited with status 1.


I thought it might be because of the sandboxing of the iphone, so i tried to read the file with ANSI-C code and created the UIImage with an NSData object. But this does not work either.

It works fine with images within the project. Is the Image too large the images are of course images from the camera roll (2 MegaPixels).

Do you have any ideas why my program crashes?
Of course I am developing for a jailbroken iPhone.
Thanks in advance!



silver83
Oct 26, 2009, 04:38 AM
on the iphone I just don't get an image object - I get null in all cases

I tried everything -
1. [UIImage imageWithContentsOfFile:] straight from /var/mobile/Media/DCIM/100APPLE/.MISC/
2. [UIImage imageWithContentsOfFile:] after copying the file to my sandbox (the copy itself works)
3. [UIImage imageWithData:[NSData dataWithContentsOfFile:]] after copying the file to my sandbox (copy works), loading to NSData (which seems to complete fine)

What's the secret ?