Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the unit of bitmap.getWidth() or bitmap.getHeight()

Tags:

The developers website simply states that getHeight() will return the bitmap's height, but can someone tell me that is in pixel unit or dp unit?

like image 967
Neoh Avatar asked Jun 12 '13 11:06

Neoh


People also ask

What is a bitmap width?

A bitmap is rectangular and has a spatial dimension, which is the width and height of the image in pixels. For example, this grid could represent a very small bitmap that is 9 pixels wide and 6 pixels high or, more concisely, 9 by 6: By convention, the shorthand dimension of a bitmap is given with the width first.

What is the bitmap in Android?

A bitmap (or raster graphic) is a digital image composed of a matrix of dots. When viewed at 100%, each dot corresponds to an individual pixel on a display. In a standard bitmap image, each dot can be assigned a different color. In this instance we will simply create a Bitmap directly: Bitmap b = Bitmap.

How do I change the bitmap color of a specific pixel in Android?

To set the colors of the pixels in your pixels array, get values from the static methods of Android's Color class and assign them into your array. When you're done, use setPixels to copy the pixels back to the bitmap.


Video Answer


2 Answers

It's pixel. In Java code you usually work with pixels, e.g. a view's width and height.

like image 64
vRallev Avatar answered Sep 23 '22 18:09

vRallev


After Hours of Experimenting I found that it actually return height in dp units.You can verify it by changing the device screen in emulator.

like image 20
Gaurav Maan Avatar answered Sep 23 '22 18:09

Gaurav Maan