Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the RGB pixel format?

Shulou Source: shulou.com Published: 2022-06-02 01:53:10 09月11日 Update

What this article shares with you is about what the RGB pixel format is. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Let's take a look at it.

Explain the pixel format of RGB, the mainstream are RGB565,RGB555, RGB24,RGB32, ARGB32, each format according to the introduction, storage schematic map, and the method of obtaining specific pixels to explain. Next, let's get down to business:

RGB565:

a. Overview:

In RGB565 format, each pixel is represented by 16 bit, 2 bytes, 1 WORD, R, G, B are represented by 5, 6, 5 bit respectively, hence the name.

b. Storage hint:

c. Method to get specific pixel values:

According to the storage mode of RGB565, we can get the value of RMagne GMagne B component. Now assume that the variable that stores a pixel in the computer is color, and the data type is short. Then there are:

R = color & 0xF800, (get 5 bit of high bytes)

G = color & 0x07E0, (get the middle 6 bit)

B = color & 0x001F, (get 5 low-byte bit)

2. RGB55:

a. Overview:

RGB55, which means that a pixel is represented by 16 bit = = 2 bytes = = 1 WORD, but the highest bit is not needed. R, G, B are represented by 5 bit each.

b. Storage hint:

c. Method to get specific pixel values:

According to the storage mode of RGB565, we can get the value of RMagne GMagne B component. Now assume that the variable that stores a pixel in the computer is color, and the data type is short. Then there are:

R = color & 0x7C00, (get 5 bit of high bytes)

G = color & 0x03E0, (get the middle 5 bit)

B = color & 0x001F, (get 5 low-byte bit)

3.RGB24:

a. Overview:

RGB24, a pixel is represented by 24 bit = = 3 bytes, and the R, G and B components are represented by 8 bit respectively.

b. Storage hint (note that the RGB24 format is stored as BGR):

c. Method to get specific pixel values:

According to the storage mode of RGB565, we can get the value of RMagne GMagne B component. Now assume that the variable that stores a pixel in the computer is color, and the data type is int. Then there are:

R = color & 0x000000FF

G = color & 0x0000FF00

B = color & 0x00FF0000

4.RGB32:

a. Overview:

RGB32, a pixel is represented by 32 bit = = 4 bytes = = 2 WORD, R, G, B components are represented by 8 bit, the storage order is B, G, R, and the last 8 bytes are reserved.

b. Storage hint:

c. Method to get specific pixel values:

According to the storage mode of RGB565, we can get the value of RMagne GMagne B component. Now assume that the variable that stores a pixel in the computer is color, and the data type is short. Then there are:

R = color & 0x0000FF00

G = color & 0x00FF0000

B = color & 0xFF000000

5. ARGB32:

a. Overview:

ARGB32 is similar to RGB32, except that RGB32 retains eight BIbit to represent transparency, that is, the value of alpha.

b. Storage hint:

c. Method to get specific pixel values:

According to the storage mode of RGB565, we can get the value of RMagne GMagne B component. Now assume that the variable that stores a pixel in the computer is color, and the data type is short. Then there are:

R = color & 0x0000FF00

G = color & 0x00FF0000

B = color & 0xFF000000

A = color & 0x000000FF

The above is what the RGB pixel format is, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Pixel storage byte format component method method variable data type computer a.scoreb.scorec don't use more knowledge article different practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology NVidia Shulou Tech Info Linux