我有代码将图片和视频上传到Face Book .. 但我不知道如何将图像从图库转换为图像的字节数。还有数据以字节为单位..任何人都可以帮助我????
*Upload picture,
Bundle params = new Bundle();
params.putByteArray("picture", <image in bytes>);
params.putString("message", "Have fun");
mAsyncRunner.request("me/photos", params, "POST", new SampleUploadListener());*
this is code for upload images...
*Upload video,
Bundle params = new Bundle();
param.putString("filename", <dataName>);
param.putByteArray("video", <data in bytes>);
mAsyncRunner.request("me/videos", param, "POST", new SampleUploadListener());**
this is code for upload images...
Any one know how code for my question please post.....
提前致谢
答案 0 :(得分:1)
试一试 -
FileInputStream is = new FileInputStream(new File(filePath));
ByteArrayOutputStream bs = new ByteArrayOutputStream();
int data;
while((data != is.read()) != -1)
bs.write(data);
is.close();
byte[] raw = bs.toByteArray();
bs.close();
答案 1 :(得分:0)
这是将位图转换为字节的一种方法:
public static byte[] bitmapToByteArray(Bitmap bitmap){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 0, baos);
return baos.toByteArray();
}