Android Question [absolutly NOT solved] About dpi (night question!)

LucaMs

Expert
Licensed User
Longtime User
The display of my laptop has 92 dpi: how many dips are they on a smartphone?

I know, it depends on the characteristics of the display of the smartphone.
But I guess there is a way to make this calculation.

I'm sure that some super expert (Klaus ) already has the answer.

[I forgot one important thing: actually, I would need to know the relationship between the pixels on my laptop and dips.]
 

LucaMs

Expert
Licensed User
Longtime User

Yes, using 100%x and 100%y the error is there.


We should use something like:

If jpgW <= pnlW and jpgH <= pnlH then
' no problem
else
diffW = jpgW - pnlW
diffH = jpgH - pnlH

and then choose the smaller difference... etc.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I was aware of all the questions you ask in your post, but I just answered your question.

1) We need to load the bitmap and the we know the original dimensions and can display it correctly.

2) Like above

3) That's my secret !
Joke beside, I did some tests to adapt the scale to give concrete values.
It would be possible to add a scaling routine into the code.
I did it in a Basic4PPC map program.
If you know the physical dimensions of two lines in the image you can move the cursor on the first line memorize the pixel position, move the cursor to the second line and calculate the scale because you know the physical dimension between the two lines and the number of pixels between these two lines.

4) Sure, this can be done. Might be confusing for the user.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Even the window for details! Great Klaus!
(uhm. magnification ..? LOL I'm kidding!)

Strangely, has increased the need for memory. In two emulators that have little memory the program stops.

I want to study well the code and appreciate it fully.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
What kind of emulators are these ?
What SDK are you using ?
I tested with a 1280 / 800 / 240 emulator and it works as expected.
It seems that the top coordinate is wrong in your examples.
Add the lines below and look what happens with DrawingTop.
B4X:
    Private bmpDrawing As Bitmap
    bmpDrawing.Initialize(File.DirAssets, "cerchio.jpg")
    Log("bmpDrawing.Width = " & bmpDrawing.Width)
    Log("bmpDrawing.Height = " & bmpDrawing.Height)
  
    If bmpDrawing.Width / bmpDrawing.Height > 100%x / 100%y Then
        DrawingWidth = 100%x
        DrawingHeight = 100%x / bmpDrawing.Width * bmpDrawing.Height
        DrawingLeft = 0
        DrawingTop = (100%y - DrawingHeight) / 2
    Else
        DrawingHeight = 100%y
        DrawingWidth = 100%y / bmpDrawing.Height * bmpDrawing.Width
        DrawingTop = 0
        DrawingLeft = (100%x - DrawingWidth) / 2
    End If
    Log("100%x = " & 100%x)
    Log("100%y = " & 100%y)
    Log("W = " & DrawingWidth)
    Log("H = " & DrawingHeight)
    Log("L = " & DrawingLeft)
    Log("T = " & DrawingTop)
    rectFullScreen.Initialize(DrawingLeft, DrawingTop, DrawingLeft + DrawingWidth, DrawingTop + DrawingHeight)
 

Attachments

  • Appartment5.png
    16.6 KB · Views: 161
Upvote 0

klaus

Expert
Licensed User
Longtime User
Strange, because the calculations are OK.
1024 / 600 = 1.707
1280 / 750 = 1.707
The width / heigth ratio is repected.
The top value of 25 is also correct.
So I don't know nor understand what happens in the Emulator.

What SDK version do you use for the Emulator, I use
Android API 20 Rev 1
Android SDK Tools Rev 23
Android Platform-tools Rev 20
Android Build-tools Rev 20
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…