Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
133 views
in Technique[技术] by (71.8m points)

java - Format of TYPE_INT_RGB and TYPE_INT_ARGB

Could anyone explain for me how java stores color in TYPE_INT_RGB and TYPE_INT_ARGB ?
Do these lines of code work properly for calculating red, green and blue ?

int red= (RGB>>16)&255;
int green= (RGB>>8)&255;
int blue= (RGB)&255;

And what about TYPE_INT_ARGB ? How can I get red, green and blue from TYPE_INT_ARGB?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The TYPE_INT_ARGB represents Color as an int (4 bytes) with alpha channel in bits 24-31, red channels in 16-23, green in 8-15 and blue in 0-7.

The TYPE_INT_RGB represents Color as an int (4 bytes) int the same way of TYPE_INT_ARGB, but the alpha channel is ignored (or the bits 24-31 are 0).

Look the javadoc of java.awt.Color and java.awt.image.BufferedImage.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...