Android Question About size of bitmap

dreamworld

Active Member
Licensed User
Longtime User
When a bitmap is loaded from a file, are its property width and height dip values?
A sample from B4A writes codes in the following way:
w = bitmap1.width * 100dip / 100
From this line of code, I guess that the width of a bitmap is not dip value.

And if an imageview load a bitmap from file, can it auto adjust the size of the bitmap?
If not, would the image become very small on HD screen?
 

dreamworld

Active Member
Licensed User
Longtime User
do we need to convert the size of bitnap to dip, if we draw with its size?

Dim Bitmap1 As Bitmap Bitmap1.Initialize(File.DirAssets, "X.jpg") Dim DestRect As Rect DestRect.Initialize(0, 0, Bitmap1.Width, Bitmap1.Height) Canvas1.DrawBitmap(Bitmap1, Null, DestRect)

Or

DestRect.Initialize(0,0,Bitmap1.Width * 1dip, Bitmap1.Height * 1dip)
 
Last edited:
Upvote 0

dreamworld

Active Member
Licensed User
Longtime User
And when an imageview load a bitmap, can it automatically convert the size of the bitmap to dip before drawing it. In this case, we are unable to manually convert the size of the bitmap to dip, if the gravity is center.
 
Upvote 0

dreamworld

Active Member
Licensed User
Longtime User
Which red line is better?

Dim Bitmap1 As Bitmap Bitmap1.Initialize(File.DirAssets, "X.jpg")
Dim DestRect As Rect

DestRect.Initialize(0, 0, Bitmap1.Width, Bitmap1.Height)
DestRect.Initialize(0, 0, Bitmap1.Width * 1dip, Bitmap1.Height * 1dip)


Canvas1.DrawBitmap(Bitmap1, Null, DestRect)
 
Upvote 0
Top