으로 변환합니다. 이것은 테스트 계기와 관련이 있지만 C# 코드에서 더 도움이 필요합니다. 나는 내 질문에 대해 더 많이 설명했다. 나는 계기에 명령을 보내고 나는 계기에서 다만 자료를 받는다. 받은 데이터는 실제 형식 (바이너리)이고 나는 그냥 문자열 변수에 넣습니다. 여기에 내가 C#, gif 데이터를 이진 배열
http://i.stack.imgur.com/UcYqV.png
다음 내가 원하는 내가이 문자열이 바이트 배열을 변환 할 것입니다 .. 문자열 안에 무엇이 캡처. 내 목표는 내 PC에 PNG 파일을 만들기 때문에. 계기 설명서는이 반환 된 데이터가 gif 형식이지만 실제 유형을 반환했다. 문제 포인트는 바이트 배열로 변환 할 때 문제가 있다는 것입니다 ... 누구나 이런 종류의 experiance가 있습니까? /// below is just send command to instrument that i want " Returns an image of the display in .gif format "
my6705B.WriteString("hcop:sdump:data?", true);
string image_format = my6705B.ReadString();
/// what's inside string image_format ??![i attached screenshot png file. this is what i received from instrument. (manual said this is Returns an image of the display in .gif format)][1] ![png file][2]
http://i.stack.imgur.com/UcYqV.png
/// now here i think i did something wrong,
/// the goal is i want change this return data to gif or png or image file.
/// any solution is ok for me
/// i just try that change this data to byte array and then try to change image file.
/// i think some error here because my code success to convert byte array then create image,,, error
//// i believe that i did something wrong in convert byte array.....
System.Text.UnicodeEncoding encode = new System.Text.UnicodeEncoding();
byte[] byte_array22 = encode.GetBytes(image_format);
MemoryStream ms4 = new MemoryStream(byte_array22);
Image image = Image.FromStream(ms4); //// error point
image.Save(@"C:\Users\Administrator\Desktop\imageTest.png");
난 내 설명 있다고 생각
코멘트입니다. 내 목표는 gif 데이터를 이미지 파일로 변환한다는 점을 다시 설명하겠습니다. instrument give us 디스플레이 이미지를 .gif 형식으로 반환합니다. 이 데이터를 문자열 배열로 받았습니다. < 이것이 정확한지 아닌지는 모르겠지만 지금은 문자열 배열을 넣은 다음>이 GIF 데이터로 png 또는 jpg 파일로 보내고 싶습니다.조언을주십시오.
조셉 최
16 비트 유니 코드가 아닌 ASCII 문자열을 읽어야합니다. 현재 encode.GetBytes (image_format)는 { '#', '\ 0', '0', '\ 0', 'G', '\ 0', 'I', '\ 0' '0', '8', '\ 0', '9', '\ 0'...} 다른 API를 사용해야하거나 Encoding.ASCII.GetBytes를 사용하여 image_format를 ASCII로 변환해야합니다.(). – nitrocaster
내가 할 수있는 한 가지는 계측기 데이터 형식이 ASC이므로 REAL 형식으로 변경할 수 있습니다. 그럼 우리는 다른 방법으로 할 수 있습니까 ?? –
필자는 요점은 악기가 오름차순 또는 실제 형식을 반환 할 수 있다고 생각합니다. 그래서 내가 한 일은 오름차순 형식이고 Encoding.ASCII.GetBytes()를 변경합니다. 그러나 MemoryStream ms4에 오류 = 새로운 MemoryStream (byte_array22); 이미지 이미지 = Image.FromStream (ms4, true, true); –