[英]do you think http protocol mix character stream with byte stream is not a good design
[英]How do you “mix” colors as mentioned in the Material Design Guidelines?
如果您要的是算法,则获得两种颜色的4个整数数组,分别为alpha,red,green,blue,分别将它们相加,然后找到新数组的最大值,然后执行max_value / 255,存储该值在变量中,然后除以数组中的每个数字。 希望我没有弄清楚我的段落。 使用BufferedImage获取像素的颜色,然后将其与所需的颜色混合。
示例代码:
public int mixColor(int color,int color2) {
int red1=(color&0xff0000)>>>16,green1=(color&0xff00)>>>8,blue1=(color&0xff);
int red2=(color2&0xff0000)>>>16,green2=(color2&0xff00)>>>8,blue2=(color2&0xff);
int nred=red1+red2,ngreen=green1+green2,nblue=blue1+blue2;
double maximum=Math.max(nred,Math.max(ngreen,nblue));
double ratio=maxiumum/255;
double totalRed=nred/ratio,totalGreen=ngreen/ratio,totalBlue=nblue/ratio;
int result=(((int)totalRed<<16)|((int)totalGreen<<8)|((int)totalBlue));
return result;
}
然后,您可以编写新的Color(mixColor(color1,color2))`以获得所需的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.