Click here to Skip to main content
13,736,558 members
Rate this:
Please Sign up or sign in to vote.
See more:

I have been struggling with an issue for the last couple of days and I have not been to find a solution.

I am calling a specific REST API from my C# project and as a return I am getting a strange looking string.
I know that this string is suppose to be an Image but I am not been able to convert it:

The string (First Part) looks as follows:
"����\0\u0010JFIF\0\u0001\u0001\u0001\0�\0�\0\0��\0ZExif\ ........."


I know this is a JPEG File and the second a PNG but it doesn't matter what I do I am not able to convert it.

Note: I do not have access to the code of the REST API Server so I am only able to get the string response.

Does anybody know what format this is and how to get this back into a bitmap format?

What I have tried:

var result = coreApi.CoreGetGalleryImageV1("string", 188, 188);

byte[] array = Encoding.UTF8.GetBytes(result);
var ms = new MemoryStream(array);

Image x = Image.FromStream(ms);
Posted 10-Nov-17 3:50am
Richard MacCutchan 10-Nov-17 10:53am
Why are you trying to convert binary data to a character encoding? If the data is an image then it is just a stream of bytes and must be saved in exactly that format.
Patrick Kasteel 12-Nov-17 9:54am
I Richard,

The Variable "result" is returned as a string.

I am not trying to save it... It needs to to be attached to a image control

Richard MacCutchan 12-Nov-17 10:14am
You need to contact the providers of the REST service to find out how to deal with the returned data.
Patrick Kasteel 12-Nov-17 10:19am
Thank Richards,

Don't want to sound ungrateful but it was the first thing I did but no reaction so far.
But surely there is a way of converting that particular string to Binary value that can be used?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web05-2016 | 2.8.180920.1 | Last Updated 10 Nov 2017
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100