1

我想将存储在 RMS 中的图像发送到服务器。为此,我将捕获的图像存储在 RMS 中。我可以成功访问它并可以通过设备显示它,但是当我过去将它发送到服务器时,服务器上只出现图像名称但图像没有生成。

这是我尝试使用的行代码

    byte[] byteArrRec = LoadImagesFromRMS.objImageRecordStore.getRecord(recID);
    ByteArrayInputStream bin = new ByteArrayInputStream(byteArrRec);
    DataInputStream din = new DataInputStream(bin);                   
    int width = din.readInt();
    int height = din.readInt();
    int length = din.readInt();

    int[] rawImg = new int[width * height];

    for (int itemp = 0; itemp < length; itemp++) {
        rawImg[itemp] = din.readInt();
    }               
    Image tempImage = Image.createRGBImage(rawImg, width, height, false);
    byteArr = get_Byte_Array(tempImage);
    byteArr = get_Byte_Array(tempImage);

然后我在服务器上使用 post 方法传递了 byteArray。
但是没有生成图像,有人对此有任何想法吗?

4

2 回答 2

0
  1. 首先需要从响应中读取所有字节并存储在bytearray字节数组的一个变量()中。然后写下这段代码
  2. 从您的字节数组创建一个ByteArrayInputStream,然后使用ImageIO类从该流中读取图像。

    InputStream in = new ByteArrayInputStream(bytearray);

    BufferedImage image = ImageIO.read(in);
    

谢谢

于 2011-10-17T06:23:37.380 回答
0

您需要HttpConnection与远程服务器创建连接,创建连接后,创建一个DataOutputStream与该变量关联的HttpConnection变量。现在将字节数组写入该DataOutputStream变量并将其作为"POST"方法发送。如果字节数组的大小非常大,请尝试分块发送..

于 2011-11-03T07:34:58.423 回答