Browse Source

随机颜色范围会导致255取不到

neko 5 years ago
parent
commit
699e14acac
1 changed files with 7 additions and 1 deletions
  1. 7 1
      hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java

+ 7 - 1
hutool-core/src/main/java/cn/hutool/core/img/ImgUtil.java

@@ -61,6 +61,12 @@ public class ImgUtil {
 	public static final String IMAGE_TYPE_BMP = "bmp";// 英文Bitmap(位图)的简写,它是Windows操作系统中的标准图像文件格式
 	public static final String IMAGE_TYPE_BMP = "bmp";// 英文Bitmap(位图)的简写,它是Windows操作系统中的标准图像文件格式
 	public static final String IMAGE_TYPE_PNG = "png";// 可移植网络图形
 	public static final String IMAGE_TYPE_PNG = "png";// 可移植网络图形
 	public static final String IMAGE_TYPE_PSD = "psd";// Photoshop的专用格式Photoshop
 	public static final String IMAGE_TYPE_PSD = "psd";// Photoshop的专用格式Photoshop
+	
+	/**
+	 * RGB颜色范围上限
+	 */
+	private static final int RGB_COLOR_BOUND = 256;
+	
 
 
 	// ---------------------------------------------------------------------------------------------------------------------- scale
 	// ---------------------------------------------------------------------------------------------------------------------- scale
 
 
@@ -1952,7 +1958,7 @@ public class ImgUtil {
 		if (null == random) {
 		if (null == random) {
 			random = RandomUtil.getRandom();
 			random = RandomUtil.getRandom();
 		}
 		}
-		return new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255));
+		return new Color(random.nextInt(RGB_COLOR_BOUND), random.nextInt(RGB_COLOR_BOUND), random.nextInt(RGB_COLOR_BOUND));
 	}
 	}
 
 
 	/**
 	/**