如何将我的Bitmap图像保存到parseObject? 这是我的代码
Bundle extras = getIntent().getBundleExtra("extras");
Bitmap thumbnail = (Bitmap) extras.get("data");
ImageView img = (ImageView)findViewById(R.id.imageview1);
img.setImageBitmap(thumbnail)
parseObject代码
ParseObject movie = new ParseObject("movies");
movies.put("title", title.getText().toString());
movies.put("description", description.getText().toString());
movies.saveInBackground();
Toast.makeText(getApplicationContext(), "Done",
Toast.LENGTH_SHORT).show()
如何将Bitmap图像保存到ParseObject“电影”中?
答案 0 :(得分:0)
您可以使用ParseFile在解析
上保存位图基本上你需要做这样的事情
ByteArrayOutputStream bos = new ByteArrayOutputStream();
rotatedScaledMealImage.compress(Bitmap.CompressFormat.JPEG, 100, bos);// can use something 70 in case u want to compress the image
byte[] scaledData = bos.toByteArray();
// Save the scaled image to Parse
photoFile = new ParseFile("image_to_be_saved.jpg", scaledData);
photoFile.saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if (e != null) {
Toast.makeText(getActivity(),
"Error saving: " + e.getMessage(),
Toast.LENGTH_LONG).show();
} else {
//filed saved successfully :)
}
}
});
然后,您可以轻松地将ParseFile放入任何ParseObject中 像这样
ParseObject po = new ParseObject("anyObject");
po.put("file",parseFileObj);
希望这有帮助