Unity's Screen.width / Screen.height doesn't reflect my android device size - unity3d

I'm using Galaxy22 Ultra so
on unity,
Debug.Log(Screen.width+"///????/"+Screen.height);
Debug.Log(Screen.currentResolution);
both says
width : 1080
height : 2316
which is not even reflect cellphone's ratio...
if width is really 1080pixel then height should be maybe 3 or 4 times bigger.
how can I get real pixel size of width and height

seems likely Galaxy S22 Ultra native resolution is 3088 x 1440. But the OS maybe reduce it to standard resolution 1080 width, this would be 75% of original size.
Thus 3088 x 1440 (75%) will be 2316 x 1080 correctly.
Screen.width // this only return your rendering screen width
Usually, some mobile will optimised the performance by reducing rendering result from native resolution.
And surely your phone screen ratio won't be 3:1 or 4:1. Normally they are between 16:9(or 1.7:1) to 21:9(or 2.3:1).

Related

Flutter MediaQuery.of(context).size.width values are different than real screen resolution

in my Flutter application I am trying to get the real screen width (that can naturally be different on each device).
I am using MediaQuery.of(context).size.width but I've noticed that the values returned do not match the real screen resolution.
For instance,
On an simulator iPhone 11 Pro Max (that has resolution 2688 x 1242) I get MediaQuery.of(context).size.width= 414
On an emulator Nexus XL (that has resolution 1440 x 2560) I get MediaQuery.of(context).size.width = 411.42857142857144
On a real device iPhone 7 (that has resolution 1,334 x 750) I get MediaQuery.of(context).size.width = 375
Does anyone know why the value returned by MediaQuery differ from the real screen resolution in pixels?
Thanks
According to the size property's documentation :
The size of the media in logical pixels (e.g, the size of the screen).
Logical pixels are roughly the same visual size across devices.
Physical pixels are the size of the actual hardware pixels on the
device. The number of physical pixels per logical pixel is described
by the devicePixelRatio.
So you would do MediaQuery.of(context).size.width * MediaQuery.of(context).devicePixelRatioto get the width in physical pixels.

Responsive image resolution iPhone vs iPad

I want to use srcset to provide 2x images for iPhone and iPad, but the 2x descriptor applies to both and the images should be different.
On both devices the image is full width. But on iPhone 2x of 320w is 640w and on iPad Pro 2x of 1024 is 2048w.
How could I differentiate between the two?
The x descriptor is more suited to images which width is fixed across viewports.
For variable width images, you should use the w descriptor.
For example:
<img
src="image320.jpg"
srcset="image320.jpg 320w, image640.jpg 640w, image960.jpg 960vw, image1280.jpg 1280vw, image1600.jpg 1600vw, image1920.jpg 1920vw, image2240.jpg 2240vw, image2560.jpg 2560vw"
sizes="100vw">
The w descriptor applies the screen density factor to the CSS width of the image to get the actual image width to download.
The image1920.jpg image will be downloaded by the browser for several configurations:
screen density 1 with viewport width equal to or below 1920px
screen density 2 with viewport width equal to or below 960px
screen density 3 with viewport width equal to or below 640px
etc.

use ppi to get logical resolution

I am trying to emulate the Samsung Galaxy Tab S 10.5 , and I have no idea what the screen resolution is to create an emulator. This model seems to be left off any list I found.
Full Spec & Details http://www.gsmarena.com/samsung_galaxy_tab_s_10_5-6438.php
The screen has been given the specs:
2560 x 1600 pixels, 10.5 inches (~288 ppi pixel density)
If I use 2560 x 1600 pixels as the screen size, its obviously too big. How can I work out its Device pixel Ratio? Does the ppi have anything to do with it?
The Nexus 10 is 1280 x 800, but how can I get an exact for this or any device?
EDIT
Looking at the Nexus 10 (also made by samsung), it has the same 2560 x 1600 pixels, a Device pixel Ratio of 2, a slightly smaller screen, and a slightly bigger ppi of 300. So it would make sense this tab would also be Device pixel Ratio of 2. But is there a way to work out Device pixel Ratio from specs?

CSS pixels vs device pixels on iPhone

If I specify the width of a <div> tag using CSS as 96px, how many device pixels should that occupy on the screen of a first generation iPhone?
I added <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> to the page, took a screenshot on the simulator, and measured the div to be 96 device pixels wide. Now, I read the W3 spec for CSS pixels and it states that 1px is 1/96th of an inch. So 96 CSS pixels should translate to 1 inch. Since the original iPhone has a DPI of 163, one inch on the screen should occupy 163 device pixels. Why am I not getting that measurement? In other words, should 96 CSS pixels be equal to 1 inch?
I saw that the spec also mentions anchoring to a reference pixel. It seems to me that the reference pixel is simply a device pixel in this case. If I was to work backwards to get the CSS pixel values from a screenshot, would it generally be correct to assume that one device pixel equals one CSS pixel on the iPhone (non-retina display)?
Iphone pixels are like any other pixel. A 96px wide <div> is always 96px wide in any device. DPI (Dots Per Inch) just tell you the ratio between physical pixels (dots) on a screen (or paper) and inches and don't represent any size. DPI are only a ratio between pixels and a real world unit of measurement.
A 96px div would look 6x bigger in a 50 DPI screen than a 300 DPI screen.
DPI vary depending on the device or print/scan quality, therefore 1 inch is NOT always equal to 96 pixels. W3C is just saying that the absolute length units are fixed in relation to each other (it is just an arbitrary approximation to make CSS units consistent). This does not mean that real world units of measurement (inches, cm) can be given a fixed ratio to pixels.
The best help i can give you to understand this is that 1px is only and always equal to 1px. Any comparison between pixels and real world units depends on the DPI of a specific device, not on a standard like the W3C.
The absolute length units are fixed in relation to each other and
anchored to some physical measurement. They are mainly useful when the
output environment is known.

UIWebview can not display some large size image?

what's biggest size image can UIWebview handle?
the origin image size is: width 700 pixels, height 6900 pixels, And uiwebview display nothing.
iOS has the 3MB size limitation. the image size (width x height) must less than 3 * 1024*1024
I've discovered from some testing a limit on my html5 canvasses of 768*4096, or 3MB at 1 byte per pixel. The same resolution is enforced for images, as its not the original image size that matters, but the size of the bitmap that is rendered on the screen..