Home > Mobile >  According to the value of color, how to judge what kind color
According to the value of color, how to judge what kind color

Time:02-20


Mainly want to pass the color=color RGB (red, green, blue), identify the color which kinds of color, but:
Through int color=color RGB (red, green, blue) after get the color value, color value is a big negative, is overflow? To convert # color value, according to the above form threshold, the judge is red, pink and so on such a broad categories, don't know method is feasible? # at the beginning of color values and seems to be able to compare, is a bit, or convert # at the beginning of color values to decimal? I hope you, can give an idea?

CodePudding user response:

You can get the color value into the hexadecimal, compared with the table

CodePudding user response:

First look at the Color. The source of RGB
 
@ ColorInt
Public static int RGB (
@ IntRange (from=0, to=255) int red,
@ IntRange (from=0, to=255) int green,
@ IntRange (from=0, to=255) int blue) {
Return 0 xff000000 | (red & lt; <16) | (green & lt; <8) | blue;
}

That means you get int color is actually the original became an int type hexadecimal representation, in computer principle, a color has a scale of 0-255 to dec said it takes two, binary representation takes up eight, so three colors occupied 24, coupled with the transparency, occupies 32 bit, just a value is a 32-bit int type, so you can put a RBG color expressed as int, but note that although int type is a 32-bit said, but there is a say of plus or minus, in fact only 32-bit value, so you use color, RGB () to get an int value, the possibility of a negative number,

CodePudding user response:

refer to the second floor qq_1113502097 response:
first look at the Color. The source of RGB
 
@ ColorInt
Public static int RGB (
@ IntRange (from=0, to=255) int red,
@ IntRange (from=0, to=255) int green,
@ IntRange (from=0, to=255) int blue) {
Return 0 xff000000 | (red & lt; <16) | (green & lt; <8) | blue;
}

That means you get int color is actually the original became an int type hexadecimal representation, in computer principle, a color has a scale of 0-255 to dec said it takes two, binary representation takes up eight, so three colors occupied 24, coupled with the transparency, occupies 32 bit, just a value is a 32-bit int type, so you can put a RBG color expressed as int, but note that although int type is a 32-bit said, but there is a say of plus or minus, in fact only 32-bit value, so you use color, RGB () to get an int value, the possibility of a negative number,
modify only 31 numerical value

CodePudding user response:

reference 1st floor can't write code monkey reply:
you can get the color value into hexadecimal, compared with table
ok to try it

CodePudding user response:

reference qq_1113502097 reply: 3/f
Quote: refer to the second floor qq_1113502097 response:
to see the Color first. The source code of RGB
 
@ ColorInt
Public static int RGB (
@ IntRange (from=0, to=255) int red,
@ IntRange (from=0, to=255) int green,
@ IntRange (from=0, to=255) int blue) {
Return 0 xff000000 | (red & lt; <16) | (green & lt; <8) | blue;
}

That means you get int color is actually the original became an int type hexadecimal representation, in computer principle, a color has a scale of 0-255 to dec said it takes two, binary representation takes up eight, so three colors occupied 24, coupled with the transparency, occupies 32 bit, just a value is a 32-bit int type, so you can put a RBG color expressed as int, but note that although int type is a 32-bit said, but there is a say of plus or minus, in fact only a 32-bit value, so you use color, RGB () to get an int value, the possibility of a negative number,
modify the only 31 numerical value
thank bosses is powerful
  • Related