Questions tagged [android-bitmap]

A Java Object from android.graphics.Bitmap that represents a Bitmap.

Use android.graphics.Bitmap to create an immutable bitmap image for Android.

Android supports bitmap files in three formats:

  1. .png (preferred),
  2. .jpg (acceptable),
  3. .gif (discouraged).

To find more information :

1782 questions
1386
votes
44 answers

Strange OutOfMemory issue while loading an image to a Bitmap object

I have a ListView with a couple of image buttons on each row. When the user clicks the list row, it launches a new activity. I have had to build my own tabs because of an issue with the camera layout. The activity that gets launched for the result…
Chrispix
  • 17,941
  • 20
  • 62
  • 70
431
votes
31 answers

Android:java.lang.OutOfMemoryError: Failed to allocate a 23970828 byte allocation with 2097152 free bytes and 2MB until OOM

I want to show the Bitmap image in ImageView from sd card which is stored already. After run my application is crash and getting OutOfMemoryError error of: (java.lang.OutOfMemoryError: Failed to allocate a 23970828 byte allocation with 2097152 free…
androidTag
  • 5,053
  • 7
  • 19
  • 28
324
votes
7 answers

Get Bitmap attached to ImageView

Given ImageView image = R.findViewById(R.id.imageView); image.setImageBitmap(someBitmap); Is it possible to retrieve the bitmap?
lemon
  • 9,155
  • 7
  • 39
  • 47
268
votes
24 answers

How to get Bitmap from an Uri?

How to get a Bitmap object from an Uri (if I succeed to store it in /data/data/MYFOLDER/myimage.png or file///data/data/MYFOLDER/myimage.png) to use it in my application? Does anyone have an idea on how to accomplish this?
ilredelweb
  • 3,091
  • 4
  • 17
  • 14
196
votes
8 answers

Saving and Reading Bitmaps/Images from Internal memory in Android

What I want to do, is to save an image to the internal memory of the phone (Not The SD Card). How can I do it? I have got the image directly from the camera to the image view in my app its all working fine. Now what I want is to save this image from…
usamazf
  • 3,195
  • 4
  • 22
  • 40
166
votes
7 answers

Android Bitmap to Base64 String

How do I convert a large Bitmap (photo taken with the phone's camera) to a Base64 String?
Pankaj Singh
  • 2,241
  • 2
  • 16
  • 16
159
votes
18 answers

"Bitmap too large to be uploaded into a texture"

I'm loading a bitmap into an ImageView, and seeing this error. I gather this limit relates to a size limit for OpenGL hardware textures (2048x2048). The image I need to load is a pinch-zoom image of about 4,000 pixels high. I've tried turning off…
Ollie C
  • 28,313
  • 34
  • 134
  • 217
85
votes
4 answers

What is the difference between Bitmap and Drawable in Android?

I googled but i couldn't find any article to describe about the difference between Bitmap and Drawable in Android.
Nikhil C George
  • 1,207
  • 1
  • 10
  • 14
73
votes
9 answers

Scale image keeping its aspect ratio in background drawable

How do I make a background image fit the view but keep its aspect ratio when using as a background drawable XML? None of 's android:gravity values gives the desired effect.
tilex
  • 1,744
  • 1
  • 17
  • 32
65
votes
5 answers

Android- how can I convert android.net.Uri object to java.net.URI object?

I am trying to get a FileInputStream object on an image that the user selects from the picture gallery. This is the android URI returned by android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI content://media/external/images/media/3 When I…
lostInTransit
  • 70,519
  • 61
  • 198
  • 274
65
votes
8 answers

How to use RoundedBitmapDrawable

Has anyone managed to use RoundedBitmapDrawable? Correct me if I'm wrong, but to my understanding, it makes a circular image from a regular rectangular image. What I've tried so far is…
gian1200
  • 3,670
  • 2
  • 30
  • 59
64
votes
6 answers

Drawable to byte[]

I have an image from the web in an ImageView. It is very small (a favicon) and I'd like to store it in my SQLite database. I can get a Drawable from mImageView.getDrawable() but then I don't know what to do next. I don't fully understand the…
David Shellabarger
  • 1,523
  • 2
  • 15
  • 23
44
votes
6 answers

android get Bitmap or sound from assets

I need to get Bitmap and sound from assets. I try to do like this: BitmapFactory.decodeFile("file:///android_asset/Files/Numbers/l1.png"); And like this: getBitmapFromAsset("Files/Numbers/l1.png"); private Bitmap getBitmapFromAsset(String…
Val
  • 4,225
  • 8
  • 36
  • 55
42
votes
5 answers

Android - ImageView: setImageBitmap VS setImageDrawable

What is the difference between setImageBitmap and setImageDrawable? I have an image which I would like to set dynamically from file. The tutorial that I followed says to convert my Bitmap to a BitmapDrawable then set it using setImageDrawable. I've…
meeeee
  • 2,929
  • 3
  • 22
  • 25
39
votes
6 answers

Flip a Bitmap image horizontally or vertically

By using this code we can rotate an image: public static Bitmap RotateBitmap(Bitmap source, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(source, 0, 0, source.getWidth(),…
activity
  • 2,653
  • 3
  • 20
  • 44
1
2 3
99 100