如何创建一个从位图在Android中活动的Blob? [英] How to Create a Blob from Bitmap in Android Activity?

查看:225
本文介绍了如何创建一个从位图在Android中活动的Blob?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想entitly创造新的MYIMAGE在<上市href="http://stackoverflow.com/questions/1513603/how-to-upload-and-store-an-image-with-google-app-engine-java">How上传和存储与谷歌应用程序引擎的图像。

I'm trying to create new MyImage entitly as listed in How to upload and store an image with google app engine.

现在我没有使用任何形式。我的Andr​​oid应用程序,获取开放的,从画廊:

Now I'm not using any Form. I have Android app that gets Uri from Gallery :

m_galleryIntent = new Intent();
m_galleryIntent.setType("image/*");
m_galleryIntent.setAction(Intent.ACTION_GET_CONTENT);

m_profileButton.setOnClickListener(new OnClickListener()
{
    public void onClick(View v) 
    {
        startActivityForResult(Intent.createChooser(m_galleryIntent, "Select Picture"),1);      
    }
});

和我使用的URI来创建位图。
如何创建一个斑点在从位图我的客户?
什么罐子我不得不添加到我的Andr​​oid项目?

And I'm using the Uri to create a Bitmap.
How can I create a Blob In my client from the Bitmap?
And what jars i'll have to add to my android project?

这是使用一滴有道?
我的主要目标是为了节省从Android在GAE数据存储uplodaed的图像,现在用这个工具,适当或疗法是更好的办法? Thatks。

Is this a proper way to use Blob?
My main goal is to save an image uplodaed from an android in the GAE datastore, Am Using this tools properly or ther is better way? Thatks.

推荐答案

您需要将您的位图字节[] 之后,你可以将其存储在数据库中的一个斑点。

You have to convert your Bitmap into a byte[]and after you can store it in your database as a Blob.

要转换位图字节[] ,你可以这样做:

To convert a Bitmap into a byte[], you can use this :

Bitmap yourBitmap;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
yourBitmap.compress(Bitmap.CompressFormat.PNG, 100, bos);
byte[] bArray = bos.toByteArray();

我希望这是你想要的。

I hope it's what you want.

这篇关于如何创建一个从位图在Android中活动的Blob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆