在 android 中将解析文件图像转换为字节

convert parsefile image to byte in android

假设我有一个 ParseFile "myimage"

如何在 android 编程中将 "myimage" 从 ParseFile 转换为 byte[] 类型?

我是编程新手,parse.com android。任何帮助将不胜感激。

谢谢!

-已编辑-

我正在尝试将 ParseFile myimage 转换为字节,以便我可以将它传递给我的 NewActivity.class

Bitmap bt = BitmapFactory.decodeResource(getResources(), myimage);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bt.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();

Intent intent = new Intent(this, NewActivity.class);
intent.putExtra("image", byteArray);
startActivity(intent);

使用ParseFile的getDataInBackground()方法直接从ParseImage获取byte[]

ParseFile myImage;
myImage.getDataInBackground(new GetDataCallback() {

  @override
  public void done(byte[] data, ParseException e) {
    if (e == null) {

        Intent intent = new Intent(this, NewActivity.class);
        intent.putExtra("image", data);
        startActivity(intent);

    } else {
       //byteArray not retrieved from parseImage handle the exception

    }
  }
});