Research on the display effect of Android image resources

Source: Internet
Author: User

Formats and features of image resources supported by Android

The Android system supports common image resource formats, such as JPG, PNG, and GIF. The main image formats are as follows:

1. Features of GIF images

Transparency:GIF is a Boolean transparent type, which can be both fully transparent and non-transparent, but is not translucent (alpha transparent ).

Animation:GIF supports animation.

No loss:GIF is a lossless image format, which means you can perform any operation on GIF images without causing loss of image quality.

Horizontal scan:GIF is compressed using an algorithm called LZW. When the GIF is compressed, pixels are compressed from top to bottom horizontally, which also means that under the same conditions, the horizontal GIF image is smaller than the vertical GIF image. For example, 500*10 images are smaller than 10*500 images.

Progressive display of intervals:GIF supports progressive display of selectable intervals

From the above features, we can see that GIF images of only 256 colors are not suitable for photos, but they are suitable for images with low color requirements (such as icons and charts). They are not the best choice, we will see later that PNG is the best choice.

2. JPEG image features

Transparency and Animation:It does not support transparency or animation.

Loss:In addition to rotation (only 90, 180, 270 degrees rotation), cropping, from standard type to advanced type, editing the original image data, all other operations on JPEG images will cause quality loss. Therefore, we generally use PNG as the transition format during the editing process.

Step-by-Step display of the line:It supports step-by-step display (but IE does not support this attribute, but IE will display when the entire image information is fully reached ).
It can be seen that JPEG is the most suitable for photography images and digital cameras on the Web (Android wallpaper is JPG by default ).

3. Analysis of images in PNG format

The PNG image format includes many subclasses, but in practice it can be divided into 256-color PNG (png8) and full-color PNG (png24, png32 ), you can use a 256-color PNG instead of GIF, and a full-color PNG instead of JPEG.

Transparency:PNG fully supports Alpha transparency (transparent, translucent, and opaque ).

Animation:It does not support animation.

No loss:PNG is a lossless image format, which means that you can perform any operation on the PNG image without compromising the image quality. This also enables PNG to be used as a horizontal scan of the Transition format edited by JPEG, like GIF. PNG is also horizontally scanned, which means that the horizontal repeating color is smaller than the vertical repeating color.

Progressive display of intervals:It supports progressive display at intervals, but will increase the image size.

Compare other image formats with PNG:As we all know, GIF is suitable for graphics, JPEG is suitable for photos, and PNG series are both suitable.

A. Compared with GIF: PNG 8, apart from animation, PNG 8 has all the features of GIF, but it is more advantageous than GIF in that it supports Alpha transparency and better compression. Therefore, in most cases, you should use png8 instead of GIF (except for a very small image GIF with better compression ).

B. compared with JPEG: JPEG is better than full-color PNG, so JPEG is also suitable for photos, but it is easy to cause quality loss during JPEG editing, therefore, the full-color PNG is suitable for editing the JPEG transition format.

 

Photoshop:

1. Bit depth & Channel

In Photoshop, click the image, and select the channel depth of the image. What is the difference between 8-bit, 16-bit, and 32-bit? Is it like the 24-and 32-Bit Bitmap that we often call a concept?

A. First, here the bits represent the three base colors of red, green, and blue, which respectively have the power of 2 N (8, 16, and 32. The wider the number of digits, the more colors it can represent and the more authentic it is. Of course, the larger the image size, the longer it takes to process the image. In addition, all Photoshop built-in filters support 8-bit channels, and some 16-and 32-bit channels do not support filters, especially third-party plug-ins.

B. Of course, the answer to the second question is no. We can use three base colors to form any specific color. The bit depth in Photoshop refers to the base color. We often say that 32-bit images refer to a specific color. We have a common 8-bit RGB image with 24 digits in three channels. That is, a 24-bit RGB image contains about 16.7 million colors. Argb adds an alpha channel based on the original true color to make the image transparent, which forms the 32 bitmap that we often call. As for the 16-and 32-bit depth, it is generally used only in the professional field. The principle is the same. If you need to understand it, you can just calculate it yourself;

2. Add Noise

This is a very good practice, the principle is that the 24-bit gradient of the true color map with a 16-bit enhanced color display will appear in a circle of halo like the contour distortion. Adding a tiny noise to reduce the definition of the image will balance the halo distortion and improve the senses. The operation is the dot filter, mixed color, add the mixed color, the value should not exceed 1.5.

3. Storage is in the Web and device format

In Photoshop, the Web and mobile devices are adapted and compatible. The reason is that most of Nokia's function machines only support enhanced colors, so in this mode, you can output appropriate image resources. As one of the best mobile systems, Android fully supports the highest specifications, but it does not rule out low-end positioning. In order to save costs, devices are made into enhanced colors.

Android supports the following bits:

As mentioned above, the android system provides good support for mainstream image support formats. The following definitions are made in the source code:

Ø alpha_8: The value is 8. The graphic parameter is represented by one byte and is an 8-Bit Bitmap.

Ø argb_4444: 4 + 4 + 4 + 4 = 16. The graphic parameters are represented by two bytes, which are 16-bit bitmaps.

Ø argb_8888: 8 + 8 + 8 + 8 = 32. The graphic parameters are represented by four bytes and are 32-bit bitmaps.

Ø rgb_565: 5 + 6 + 5 = 16. The graphic parameters are represented by two bytes, which are 16-bit bitmaps.

Alpha_8, argb_4444, and argb_8888 are all transparent bitmaps, that is, the letter A represents Alpha.

Argb_4444: indicates four parameters, namely A, R, G, and B. Each parameter is represented by 4 bits.

Argb_8888: indicates that there are four parameters, namely A, R, G, and B. Each parameter is represented by 8 bits.

Rgb_565: indicates that three parameters, R, G, and B, account for 5bit, 6bit, and 5bit respectively.

The default format of images in Android 2.2 and earlier versions is rgb_565. In this case, the image Resources Displayed with true colors are distorted, especially with the gradient effect. 2.3 After kernel upgrade, the default image resolution mode is changed to argb_8888, which greatly improves the support for true color image resources.

 

Conclusion:

 

UBy default, pixelformat is set to argb_8888 (32-bit) for Qualcomm 2.3 and marvel4.0 and later versions, without distortion.

4.0
2.3

UThe marvel2.3 version can have the following solutions (graphical distortion is caused by many code iterations of marvel2.3 from 2.2, and the work done by 2.2 has been continued, however, many historical issues have also been introduced, and the Image Engine GC is not well performed ):

1. Merge the modification method (low risk and moderate effect)

A. Add minor noise to the gradient image.

In marvel2.3, the two images are compared. If 1.5 of the noise is added on the left side, the image looks smoother, and the noise value may be more optimized.

B. Try to verify the effect of the gradient when using the UI plot.

C. Run the following code: getwindow (). setformat (pixelformat. rgba_8888); (PS: directly before setcontent in oncreate. The effect cannot be guaranteed, but it cannot take effect in the Marvel environment for personal authentication ).

2.Thorough revision (risk needs to be evaluated, and the effect is thorough)

Find and call the code for setting the image resolution mode in the framework or even the graphics library source code (GC) for evaluation and modification.

UThe problem is caused by hardware.

UPNG is recommended for Android resources.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.