How to create blob from bitmap in android activity?

I am trying to create a new MyImage as indicated in How to upload and save an image using the Google App Engine .

Now I do not use any form. I have an Android app that gets Uri from the 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);      
    }
});

And I use Uri to create a bitmap.
How can I create blob in my client from bitmap?
And which jars will I have to add to my Android project?

Is this the right way to use blob?
My main goal is to save the image laid out from the android in the GAE data warehouse, Am Do you use these tools correctly or better? Thatks.

+5
source share
2

Bitmap byte[] , Blob.

a Bitmap byte[], :

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

, , .

+12

:

public static byte[] getBytesFromBitmap(Bitmap bitmap) {
    if (bitmap!=null) {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 70, stream);
        return stream.toByteArray();
    }
    return null;
}

bitmap blob.

:

blob - .

+1

All Articles