0

I dont understand what happens with pixels in Virtual Display in Android when output dimensions are reduced compared to the input ones ?

When I have for example input = size of my Display = 1920x960 and I set outputs to be 1920/3 and 960/3, what happens in that case with image pixels:

  1. pixel density is increased or
  2. maybe it takes only smaller part of screen that is centered and has dimensions 640x320 or
  3. something else?

Additionally, is there a way that I can only grab center part of screen as in picture below?

Desired region

pppery
  • 3,731
  • 22
  • 33
  • 46
Milos
  • 35
  • 6
  • Hmm, the question itself doesn't seem to be a [question fit for the site](https://stackoverflow.com/help/on-topic) since it talks about how the OS handles rendering and doesn't concern any problem or a topic about programming at all. BUT your last question about screen grabbing or screen capturing does sound like a plausible question. Maybe move this thread to another Meta site ([SuperUser perhaps](https://superuser.com/))and ask your last question on a separate thread. – JumperBot_ Jul 12 '22 at 12:07
  • First question is there because I am not 100% sure how that works and maybe my second question can be solved that way. I saw tons of similar questions here so dont see anything wrong with it... – Milos Jul 12 '22 at 12:20
  • My point here is that this is supposed to be asked on a site like [SuperUser](https://superuser.com/help/on-topic) since this talks about how would the software/hardware adapt to decreasing pixel size(s) of a rendered object. It really isn't on-topic for StackOverflow because this is the place where you ask questions about programming and not hardware/software specific questions. – JumperBot_ Jul 12 '22 at 13:30
  • Also, you can get a better guarantee that someone will actually answer your questions if you ask this on a site like [SuperUser](https://superuser.com/). – JumperBot_ Jul 12 '22 at 13:32
  • Note: this question has already been [reasked on Super User](https://superuser.com/q/1731278/356789), but was then [migrated to Android.SE](https://android.stackexchange.com/q/247503/44325). – Andrew T. Jul 12 '22 at 19:22
  • Eek, can't believe this has been migrated to 2 other sites already and went unanswered. – JumperBot_ Jul 13 '22 at 02:57
  • Oh I see, you asked it with the last question in mind, I thought you were only going to ask about "[Android] how would the OS handle resizing to smaller display dimensions?" and not about " Is there a way that I can only grab center part of screen as in picture below?". My bad. – JumperBot_ Jul 13 '22 at 03:00
  • I'll watch some and dig in the AOSP, come back once I have a complete answer. – JumperBot_ Jul 13 '22 at 03:16

1 Answers1

0

By digging in the AOSP, watching, looking at a thread and experimenting~

I have come to my own (might be overly) simplified conclusion.

  1. Android calls the native Java SDK which produces the information that's needed to render a bitmap/pixels on a Java program.
  2. If the results are the same don't need to pass/copy it again to the GPU.
  3. If the results are not the same pass/copy it to the GPU to be "invalidated" then re-rendered.

Now to your question.

  1. By looking at the Bitmap class and looking at this thread It came to my mind that resizing depends on the scaling ratio passed on to the Matrix class.
  2. If resized, it will expensively create a new Bitmap that looks like something either a pretty-bad higher pixel-density or not-so-smooth lower pixel density.
  3. If the pixel-density is increased (smaller dimensions, your case) it will look squashed and if need be, the colors are averaged to the nearest neighbouring pixels. ("kind of" like how JPEG works).
  4. After resizing it will still stay to it's origin (top-left part of the rendered object) which is defined by it's X and Y coordinates.

For your second question, about screen grabbing you can take a look at this and then programatically resize the image by doing something like this:

  //...
  Bitmap.createBitmap(screenshot_bitmap, left, top, right, bottom);
  //...
JumperBot_
  • 551
  • 1
  • 6
  • 19