简体   繁体   English

不同类型的BufferedImage是什么意思?

[英]What do the different types of BufferedImage mean?

The documentation of BufferedImage is pretty ... terse. BufferedImage的文档非常简洁。

What do the different types mean? 不同类型的含义是什么? What do I get back when I call getPixel() for TYPE_INT_ARGB ? 当我为TYPE_INT_ARGB调用getPixel()时,我会得到什么? How is it different from what I get back when the type is TYPE_3BYTE_BGR ? 当类型为TYPE_3BYTE_BGR时,它与我得到的有什么不同? What about the other types? 其他类型呢?

TYPE_INT_ARGB uses Integer to save a color of pixel, like TYPE_INT_ARGB使用Integer来保存像素的颜色,如

int color = 0xAARRGGBB,

but 3BYTE_BGR uses 但3BYTE_BGR使用

byte[] color = new byte[Blue, Green, Red]

I recommend uses INT_ARGB, you can use alpha, in 3BYTE there are not channel alpha. 我建议使用INT_ARGB,你可以使用alpha,在3BYTE中没有通道alpha。 Integer is faster, than array of byte and easy, for example to get any color use: 整数比字节数组更容易,例如获取任何颜色:

(COLOR >> 16) & 0xFF; (24-16 bits are RED).
(COLOR >>  8) & 0xFF; (16- 8 bits are GREEN).
(COLOR >>  0) & 0xFF; ( 8- 0 bits are BLUE).

I always use INT_ARGB or INT_RGB (if I don't need alpha) 我总是使用INT_ARGB或INT_RGB(如果我不需要alpha)

Type represents pixel color type. Type表示像素颜色类型。

Like TYPE_INT_ARGB uses 8 bits for ALPHA component, 8 bits for RED component, 8 bits for GREEN component and 8 bits for BLUE component of color. 与TYPE_INT_ARGB类似,ALPHA组件使用8位,RED组件使用8位,GREEN组件使用8位,使用蓝色颜色组件使用8位。 So pixel color can be stored in int value. 因此像素颜色可以存储在int值中。

TYPE_3BYTE_BGR do not store ALPHA component of color. TYPE_3BYTE_BGR不存储颜色的ALPHA组件。 It uses only 3 bytes of int value. 它只使用3个字节的int值。

Like TYPE_USHORT_555_RGB uses 5 bits for each RED, GREEN and BLUE component of color. 像TYPE_USHORT_555_RGB一样,每个RED,GREEN和BLUE组件使用5位颜色。 As it uses 5 bits only, it will have limited number of colors than TYPE_INT_ARGB or TYPE_3BYTE_BGR. 由于它仅使用5位,因此它的颜色数量将少于TYPE_INT_ARGB或TYPE_3BYTE_BGR。

ALPHA component represents how image is transparent. ALPHA组件表示图像是如何透明的。

Likewise other types defines different color schemes. 同样,其他类型定义不同的配色方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM