Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Android Window Format

I have a drawing app (Android 3.x+ target) that performs a full screen copy of a Bitmap to the Canvas in onDraw(), and I want to ensure I am copying from 32bit to 32bit, per this article. I want to ensure 32bit -> 32bit so that I have the best performance and so I don't have to supply any Paint to the Canvas.drawBitmap() operation.

When I create my Bitmap, I ensure that it is done via:

mBitmap = Bitmap.createBitmap(screenWidth, screenHeight, Bitmap.Config.ARGB_8888);

Now, in my drawing Activity, I query the Window via getWindow().getAttributes().format, but am returned OPAQUE (the default value) - question, is this 32bit? In Romain's article above, he mentions that in Android 2.3, windows are now 32bit by default, but a return value of OPAQUE is not so re-assuring.

If someone could clarify what I am seeing here it would be greatly appreciated.

like image 719
Unpossible Avatar asked Jan 09 '12 16:01

Unpossible


People also ask

What is a window in Android?

A window is basically like you think of a window on the desktop. It has a single Surface in which the contents of the window is rendered. An application interacts with the Window Manager to create windows; the Window Manager creates a Surface for each window and gives it to the application for drawing.

How do I make my Android apps fit all screen sizes?

Simple, use relative layout with the set margin code. Set the margins between each text view, button, etc and it will look the same on every phone. android:layout_marginTop="10dp" // change Top to Bottom, Left or Right for what you need.


1 Answers

You are creating a 32bit-bitmap, but you are not modifying the window-format. Add a getWindow().setAttributes(attr) to ensure a full 32bit-compatibility.

like image 154
poitroae Avatar answered Oct 05 '22 10:10

poitroae