【问题标题】:Android - converting File or Byte array into a BlobAndroid - 将文件或字节数组转换为 Blob
【发布时间】:2013-04-12 22:01:09
【问题描述】:

我已经搜索了很多,但我找不到这个简单问题的答案。

我想实现以下功能之一:

public Blob getBlob(Byte[] imageByteArray){

}

public Blob getBlob(File imageFile){

}

请注意,这些函数是从 android 客户端调用的。 谢谢!

【问题讨论】:

  • 这里有一个与您类似的question 已得到答复...

标签: android file bytearray blob


【解决方案1】:
//you bitmap image first get
Bitmap bitmap = BitmapFactory.decodeFile("/path/images/image.jpg");
//take on bytearrayoutputStream to convert into blolb  so here is you blob
ByteArrayOutputStream blob = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 0 "ignore png", blob);
byte[] bitmapdata = blob.toByteArray();

【讨论】:

  • 如果我没记错的话,这个函数是 (File -> byteArray) 而不是 (File -> Blob)
猜你喜欢
  • 2012-06-06
  • 1970-01-01
  • 2016-04-14
  • 2011-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-09
  • 2014-04-14
相关资源
最近更新 更多