2

I saved an image using Coredata in my application. Then i imported the Sqlite file in another project and retrieved that Blob field and converted to NSData. Then i got a NULL value when trying to convert this NSData to UIImage.

NSData *data=UIImageJPEGRepresentation(tempImage, 1.0);

saved the above data by saving context

To get back from Sqlite ::

const char *sqlStatement = "select ID,NAME,IMAGE from CALL";
sqlite3_stmt *compiledStatement;
NSData *data=[[NSData alloc] initWithBytes: sqlite3_column_blob(compiledStatement, 2) length:sqlite3_column_bytes(compiledStatement, 2)];
UIImage * showImage= [UIImage imageWithData: data];
Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
pradyumnad
  • 553
  • 4
  • 23

1 Answers1

0

The code you are writing is correct.

Difference I found in your code and some other code on internet is:

You use: UIImageJPEGRepresentation(tempImage, 1.0);

They use: UIImagePNGRepresentation(self.coffeeImage);

Though this is not the correct solution of your question but though It may help you to investigate further in issue.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Janak Nirmal
  • 22,706
  • 18
  • 63
  • 99