java中如何用Color()方法设置出米黄、灰蓝等颜色

java中如何用Color()方法设置出米黄、灰蓝等颜色,第1张

Color类中有一个构造方法可以传入三个int值,分别代表RGB颜色的值。

Color c = new Color(int a,ing g,int b);

设置Color的RGB颜色值即可。

代码不完整,测试不了。

/

旋转为指定角度

@param bufferedimage

目标图像

@param degree

旋转角度

@return

/

public static BufferedImage rotateImage(final BufferedImage bufferedimage, final int degree){

int w= bufferedimagegetWidth();// 得到宽度。

int h= bufferedimagegetHeight();// 得到高度。

int type= bufferedimagegetColorModel()getTransparency();// 得到透明度。

BufferedImage img;// 空的。

Graphics2D graphics2d;// 空的画笔。

(graphics2d= (img= new BufferedImage(w, h, type))createGraphics())setRenderingHint( RenderingHintsKEY_INTERPOLATION, RenderingHintsVALUE_INTERPOLATION_BILINEAR);

graphics2drotate(MathtoRadians(degree), w / 2, h / 2);// 旋转,degree是整型,度数,比如垂直90度。

graphics2ddrawImage(bufferedimage, 0, 0, null);// 从bufferedimagecopy至img,0,0是img的坐标。

graphics2ddispose();

return img;// 返回复制好的,原依然没有变,没有旋转,下次还可以使用。

}

看看别人的写法

构造方法有:

Color(int rgb):用指定的组合 RGB 值创建一种不透明的 sRGB 颜色,此 sRGB 值的 16-23 位表示红色分量,8-15 位表示绿色分量,0-7 位表示蓝色分量。

Color(int r, int g, int b)

用指定的红色、绿色和蓝色值创建一种不透明的 sRGB 颜色,这三个颜色值都在 0-255 的范围内

Color(int r, int g, int b, int a)

用指定的红色、绿色、蓝色和 alpha 值创建一种 sRGB 颜色,这些值都在 0-255 的范围内。

Color(float r, float g, float b, float a)

用指定的红色、绿色、蓝色和 alpha 值创建一种 sRGB 颜色,这些值都在 00 - 10 的范围内。

Color(float r, float g, float b)

用指定的红色、绿色和蓝色值创建一种不透明的 sRGB 颜色,这三个颜色值都在 00 - 10 的范围内。

rgb三个参数的值为0-255,对应就是00-FF(这个是16进制的),所以可以直接从#FFFFFF得到rgb的值为:int r = 0xff ; int g = 0xff ; int b = 0xff ;(0x<零x>表示16进制晓得的吧)

以上就是关于java中如何用Color()方法设置出米黄、灰蓝等颜色全部的内容,包括:java中如何用Color()方法设置出米黄、灰蓝等颜色、java旋转照片颜色失真太大,求指导、怎样用Java编辑调色板(利用红蓝绿三种颜色调出所用颜色)!等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9573662.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-29
下一篇 2023-04-29

发表评论

登录后才能评论

评论列表(0条)

保存