有关Windows Phone 8.1应用程序开发中字节数组的问题? [英] Problem Regarding byte Array in windows phone 8.1 apps development?

查看:128
本文介绍了有关Windows Phone 8.1应用程序开发中字节数组的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Windows 8.1 silverlight应用程序。对于我的应用程序,我必须截取当前屏幕的屏幕截图并将屏幕截图发送到服务器。为此,我将图像转换为字节数组。问题是转换后的字节数组包含从0到255的字节,但我想要-127到127。怎么做。



我得到的字节数组样本是



I am developing a Windows 8.1 silverlight app . For my application I have to take screenshot of present screen and send the screenshot to server . For this I converted the image to byte array. The problem is the converted byte array containing bytes from 0 to 255 but i want -127 to 127 . How to do this.

sample of byte array I am getting is

255,216,255,224,0,16,74,70,73,70,0,1,1,1,0,96,0,96,0,0,255,219,0,67,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,255,219,0,67,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,255,192





所需格式为





required format is

-119,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,3,18,0,0,1,19,8,6,0,0,0,-94,7,48,71,0,0,0,4,115,66,73,84,8,8,8,8,124,8,100,-120,0,0,32,0,73,68,65,84,120,-100,-20,-35,-55,-113,-100,121,-98,-33,-9,-9,-77,-58,-66,-28,-66,49,51,-103,-36,-117,-59,98,85,-85,87,77,25,-93,-42,-76,0,73,-10,-95,-95,-117,5,75,23,-51,-63,103,-63,-14,-67,-83,-77,1,13,12,-1,3,-126,14,51,48,96,-7,96,-40,24,75,-16,-12,-72,87,77,87,-41,-50,-30,82,44,46,73,-26,-58,92,35,99,-113,120,-30,-39,124,72,38,-101,85,77,22,-103





ScreenShot取和转换为字节代码





ScreenShot taking and Converting to bytes code

WriteableBitmap bmp = new WriteableBitmap(480, 696);
               bmp.Render(LayoutRoot, null);
               bmp.Invalidate();
               var ms = new MemoryStream();
               bmp.SaveJpeg(ms, 480, 696, 0, 100);
               ms.Seek(0, SeekOrigin.Begin);
               imagebytes = ms.ToArray();





谢谢你,



thank you,

推荐答案

只是解释/在服务器端将 byte 数组转换为 sbyte 数组?只需在转换前应用偏移或转换功能。这样的事情:



just Interpret/Convert the byte array as sbyte array on the Server side? Just apply you Offset or "Transformation" function before converting. Something like this:

byte[] abyUnsigned = new byte[] { 0, 128, 255 };

sbyte[] abySigned = new sbyte[abyUnsigned.Length];
int iOffset = 128;
for (int i = 0; i < abyUnsigned.Length; i++)
{
    abySigned[i] = Convert.ToSByte(abyUnsigned[i] - iOffset);
    Console.WriteLine(abySigned[i]);



}



顺便说一句。我想知道你为什么会有这样的要求(签名的图像字节) - 我很困惑......


}

Btw. I'm wondering why you could have such a requirement (signed Image Bytes) - I'm puzzled...


这篇关于有关Windows Phone 8.1应用程序开发中字节数组的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆