Questions tagged [bitmap]

Data structure for encoding pictures as a set of bits, in which each image pixel is mapped to a bit or a group of bit. Also used for encoding other complex data where each elementary information is mapped to bits, in a similar fashion. For platform specific bitmap API, prefer more specific tags (e.g. android-bitmap or nsbitmapimagerep).

A is a general data structure that maps complex data to a large set of bits. Each elementary information is mapped to specific bits.

Bitmaps are mostly used to encode graphic data and images. Each image pixel is mapped to a bit (black & white image) or a group of bits (grey scale or color image).

Usage guidelines:

External references:

15713 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
1084
votes
22 answers

How to convert a Drawable to a Bitmap?

I would like to set a certain Drawable as the device's wallpaper, but all wallpaper functions accept Bitmaps only. I cannot use WallpaperManager because I'm pre 2.1. Also, my drawables are downloaded from the web and do not reside in R.drawable.
Rob
  • 15,041
  • 6
  • 25
  • 27
572
votes
23 answers

How to load an ImageView by URL in Android?

How do you use an image referenced by URL in an ImageView?
Praveen
  • 90,477
  • 74
  • 177
  • 219
521
votes
19 answers

Save bitmap to location

I am working on a function to download an image from a web server, display it on the screen, and if the user wishes to keep the image, save it on the SD card in a certain folder. Is there an easy way to take a bitmap and just save it to the SD card…
Chrispix
  • 17,941
  • 20
  • 62
  • 70
494
votes
11 answers

How to convert a Bitmap to Drawable in android?

How can I convert a Bitmap image to Drawable ?
Farha Ansari
  • 5,855
  • 5
  • 26
  • 22
396
votes
21 answers

How to Resize a Bitmap in Android?

I have a bitmap taken of a Base64 String from my remote database, (encodedImage is the string representing the image with Base64): profileImage = (ImageView)findViewById(R.id.profileImage); byte[] imageAsBytes=null; try { imageAsBytes =…
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
321
votes
10 answers

converting Java bitmap to byte array

Bitmap bmp = intent.getExtras().get("data"); int size = bmp.getRowBytes() * bmp.getHeight(); ByteBuffer b = ByteBuffer.allocate(size); bmp.copyPixelsToBuffer(b); byte[] bytes = new byte[size]; try { b.get(bytes, 0,…
Tom Fobear
  • 6,729
  • 7
  • 42
  • 74
304
votes
6 answers

How to set a bitmap from resource

This seems simple, I am trying to set a bitmap image but from the resources, I have within the application in the drawable folder. bm = BitmapFactory.decodeResource(null, R.id.image); Is this correct?
Beginner
  • 28,539
  • 63
  • 155
  • 235
290
votes
10 answers

Convert a bitmap into a byte array

Using C#, is there a better way to convert a Windows Bitmap to a byte[] than saving to a temporary file and reading the result using a FileStream?
Jeremy McGee
  • 24,842
  • 10
  • 63
  • 95
237
votes
10 answers

Load a WPF BitmapImage from a System.Drawing.Bitmap

I have an instance of a System.Drawing.Bitmap and would like to make it available to my WPF app in the form of a System.Windows.Media.Imaging.BitmapImage. What would be the best approach for this?
Kevin
  • 9,309
  • 12
  • 44
  • 51
222
votes
21 answers

Resize a large bitmap file to scaled output file on Android

I have a large bitmap (say 3888x2592) in a file. Now, I want to resize that bitmap to 800x533 and save it to another file. I normally would scale the bitmap by calling Bitmap.createBitmap method but it needs a source bitmap as the first argument,…
Manuel
  • 8,135
  • 10
  • 32
  • 29
189
votes
27 answers

Android: Rotate image in imageview by an angle

I am using the following code to rotate a image in ImageView by an angle. Is there any simpler and less complex method available. ImageView iv = (ImageView)findViewById(imageviewid); TextView tv = (TextView)findViewById(txtViewsid); Matrix mat = new…
rijinrv
  • 2,029
  • 2
  • 16
  • 17
187
votes
8 answers

converting drawable resource image into bitmap

I am trying to use the Notification.Builder.setLargeIcon(bitmap) that takes a bitmap image. I have the image I want to use in my drawable folder so how do I convert that to bitmap?
tyczj
  • 71,600
  • 54
  • 194
  • 296
167
votes
10 answers

How can I pass a Bitmap object from one activity to another

In my activity, I create a Bitmap object and then I need to launch another Activity, How can I pass this Bitmap object from the sub-activity (the one which is going to be launched)?
michael
  • 106,540
  • 116
  • 246
  • 346
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
1
2 3
99 100