Java – how do I decide which bufferedimage image type to use?

The Java bufferedimage class has a long list of class variables called image types, which can be used as parameters of the bufferedimage constructor

However, the Java documentation provides a minimal explanation of the purpose of these image types and how it will affect the bufferedimage to be created

My question is:

>How does the image type affect the bufferedimage to be created? Does it control the number of bits used to store various colors (red, green, blue) and their transparency? > If we just want to create, which image type should we use

>Opaque Image > transparent image > translucent image

I have read the description in Java doc many times, but we don't know how to use it For example, this one:

Solution

Use the default type unless you have specific requirements, such as saving memory or calculations or a specific native pixel format_ INT_ ARGB, 8 bits per channel, 3 channels alpha

When using 8 bits per channel, skipping the alpha channel will not affect the total memory occupied by the image, because in any case, each pixel will be packaged as int, so 8 bits will be discarded

Basically, you have:

> TYPE_ INT_ ARGB, 4 bytes per pixel, with alpha channel > type_ INT_ ARGB_ Pre, 4 bytes per pixel, the same as before, but the color has been multiplied by the alpha value of the pixel to save calculation > type_ INT_ RGB, no alpha channel > type_ USHORT_ 555_ RGB and type_ USHORT_ 565_ RGB, 2 bytes per pixel, much less color. You don't need to use it unless you have a memory limit

Then there are all the same types of formats and switching channels (e.g. BGR instead of RGB) You should select the native of the platform to reduce conversion

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>