SQLClient icon indicating copy to clipboard operation
SQLClient copied to clipboard

jpegdecompresssurface : picture decode failed : e00002d1

Open totoourworld opened this issue 8 years ago • 39 comments

jpegdecompresssurface : picture decode failed : e00002d1 I can get exact same data as image data from sql server. So i try to load image from NSData, below the code,

  • (void)process:(NSArray*)results { NSArray *table=[results objectAtIndex:0]; NSDictionary *row=[table objectAtIndex:0]; NSData *image_source=[row objectForKey:@"Company_Logo"]; UIImage *image=[[UIImage alloc] initWithData:image_source]; image=[UIImage imageWithData:image_source]; [self.imageView setImage :image]; } but the final step , it is showing like this, in here // [self.imageView setImage :image]; jpegdecompresssurface : picture decode failed : e00002d1 How can i solve this? Regards.

totoourworld avatar Jan 23 '17 16:01 totoourworld

Please try the types branch.

martinrybak avatar Jan 23 '17 17:01 martinrybak

I used types branch and used the sample project for testing but same. can you give me the source code for that? I checked the NSData *image_source=[row objectForKey:@"Company_Logo"]; by log the value. but same as data in sql. How can i use this for mapping to uiimage type? can you teach me? i want your reply. thanks . king regards,

totoourworld avatar Jan 23 '17 19:01 totoourworld

It could be related to this: https://msdn.microsoft.com/en-us/library/ms177687(v=sql.90).aspx

What version of SQL Server are you using? What data type is the column with the image? If possible, can you attach the image file here?

martinrybak avatar Jan 23 '17 19:01 martinrybak

I am using the SQL EXPRESS 2016. I used the Company_Logo(image,null) for saving/loading image.

Additionally, I am trying to load the image that saved by C# program i made. In android , the image can be read by byte array and convert that to bitmap image, and it is working. In C# , it is also working well.

but in iOS when i tried to do like that with above code , it is showing jpegdecompresssurface : picture decode failed : e00002d1

totoourworld avatar Jan 24 '17 07:01 totoourworld

1

totoourworld avatar Jan 24 '17 07:01 totoourworld

3d_apple_logo_preview_featured

totoourworld avatar Jan 24 '17 08:01 totoourworld

visual_csharp_logo1-300x230

totoourworld avatar Jan 24 '17 08:01 totoourworld

images

totoourworld avatar Jan 24 '17 08:01 totoourworld

These three pictures , i used to try. jpg file looks like that issue , but png file is not showing at all.

totoourworld avatar Jan 24 '17 08:01 totoourworld

Hello , Mr.Martin Rybak. I tried to debug the code and found something related. So, (void)process:(NSArray*)results { NSArray *table=[results objectAtIndex:0]; NSDictionary *row=[table objectAtIndex:0]; NSData *image_source=[row objectForKey:@"Company_Logo"]; UIImage image=[[UIImage alloc] initWithData:image_source]; image=[UIImage imageWithData:image_source]; [self.imageView setImage :image]; } in this code ,(NSArray) results is returning values from sql. in here , i checked the @"Company_Logo". It was NSInlineData and 4096bytes. That's why the above 5kb jpg image is not showing full. I tried to use small jpg image (for example 400bytes) , and it is showing well. Can you give me some solution for large image? Really thanks for your help. Regards.

totoourworld avatar Jan 24 '17 09:01 totoourworld

Please put a breakpoint on line 544 of SQLClient.m:

https://github.com/martinrybak/SQLClient/blob/types/SQLClient/SQLClient/SQLClient/SQLClient.m#L544

What is the value of column->size?

martinrybak avatar Jan 24 '17 18:01 martinrybak

in image type the column size is 4096

totoourworld avatar Jan 24 '17 18:01 totoourworld

column->size is 4096

totoourworld avatar Jan 24 '17 18:01 totoourworld

OK, to be sure, put a breakpoint on this line and verify that dbcollen(_connection, c) is returning 4096 for your image column.

https://github.com/martinrybak/SQLClient/blob/types/SQLClient/SQLClient/SQLClient/SQLClient.m#L261

martinrybak avatar Jan 24 '17 18:01 martinrybak

Also try changing your data type from image to varbinary(max)

martinrybak avatar Jan 24 '17 19:01 martinrybak

I tried both type, means , i saved the data to image type and varbinary(max) type and read the data using your framework. In 261 , breakpoint, the column.size is 4096 for both types , sir.

totoourworld avatar Jan 24 '17 19:01 totoourworld

OK, in the freetds docs I found the following:

text size: default value of TEXTSIZE, in bytes. For text and image datatypes, sets the maximum width of any returned column. Cf. set TEXTSIZE in the T-SQL documentation for your server.

http://www.freetds.org/userguide/freetdsconf.htm

Try adding a file called freetds.conf to your app with these contents:

[global]
text size = 10000

Then add an environment variable to your app called FREETDS whose value is the path to that file.

http://www.freetds.org/userguide/envvar.htm

See if that helps.

martinrybak avatar Jan 24 '17 19:01 martinrybak

sorry but my app means? ios project, sir?

totoourworld avatar Jan 24 '17 19:01 totoourworld

Yes, add it to your iOS project.

martinrybak avatar Jan 24 '17 19:01 martinrybak

yeah ,i added freetds.conf to SQLClint folder , but i am not sure about the environment variable adding , can you guide me a bit more , sir? thanks.

totoourworld avatar Jan 24 '17 19:01 totoourworld

http://nshipster.com/launch-arguments-and-environment-variables/

martinrybak avatar Jan 24 '17 19:01 martinrybak

freetds.conf path would be full path like this "/Volumes/Mac_Data/KO/pos_australia/latest/SQLClient_Type/SQLClient-types/SQLClient/SQLClient/SQLClient/freetds.conf" or what's the right path of freetds.conf file, sir?

totoourworld avatar Jan 24 '17 19:01 totoourworld

I added with your requirement and ran the project ntext type in sql returning column->size 8192 bytes in dbcollen(_connection, c) 164 line. but image type and varbinary is same as 4096, sir.

totoourworld avatar Jan 24 '17 20:01 totoourworld

http://stackoverflow.com/questions/12205785/getting-bundle-file-references-paths-at-app-launch

martinrybak avatar Jan 24 '17 20:01 martinrybak

I got file path using your reference source code , "/var/containers/Bundle/Application/0E8B03A5-869A-4435-AE41-21972F55CA4B/SQLClient.app/freetds.conf" so i set above path as value of FREETDS.

totoourworld avatar Jan 24 '17 20:01 totoourworld

what value would i check by debugging?

totoourworld avatar Jan 24 '17 20:01 totoourworld

00b9eedc-325f-4313-95ba-c97b0a649ffa 9f1448e2-d6b8-4b26-acb7-4323ae25c50f 14048687-816f-4288-bfd4-e90db90ac44d

totoourworld avatar Jan 24 '17 20:01 totoourworld

The value must be relative to your app. Try freetds.conf instead.

martinrybak avatar Jan 24 '17 20:01 martinrybak

I changed with your instruction and tested , again . but the column->size of image is still 4096

totoourworld avatar Jan 24 '17 20:01 totoourworld

ef9826a7-0c22-496b-91c7-dd11a662395a 4f0e0644-3328-4224-bb90-386516836e4c

totoourworld avatar Jan 24 '17 20:01 totoourworld