1058 * <code>BufferedImage</code>.
1059 *
1060 * @return a new <code>BufferedImage</code>
1061 *
1062 * @exception IllegalArgumentException if either <code>width</code> or
1063 * <code>height</code> are negative or zero.
1064 * @exception IllegalArgumentException if the product of
1065 * <code>width</code> and <code>height</code> is greater than
1066 * <code>Integer.MAX_VALUE</code>, or if the number of array
1067 * elements needed to store the image is greater than
1068 * <code>Integer.MAX_VALUE</code>.
1069 */
1070 public BufferedImage createBufferedImage(int width, int height) {
1071 try {
1072 SampleModel sampleModel = getSampleModel(width, height);
1073 WritableRaster raster =
1074 Raster.createWritableRaster(sampleModel,
1075 new Point(0, 0));
1076 return new BufferedImage(colorModel, raster,
1077 colorModel.isAlphaPremultiplied(),
1078 new Hashtable());
1079 } catch (NegativeArraySizeException e) {
1080 // Exception most likely thrown from a DataBuffer constructor
1081 throw new IllegalArgumentException
1082 ("Array size > Integer.MAX_VALUE!");
1083 }
1084 }
1085
1086 /**
1087 * Returns <code>true</code> if the given <code>Object</code> is
1088 * an <code>ImageTypeSpecifier</code> and has a
1089 * <code>SampleModel</code> and <code>ColorModel</code> that are
1090 * equal to those of this object.
1091 *
1092 * @param o the <code>Object</code> to be compared for equality.
1093 *
1094 * @return <code>true</code> if the given object is an equivalent
1095 * <code>ImageTypeSpecifier</code>.
1096 */
1097 public boolean equals(Object o) {
1098 if ((o == null) || !(o instanceof ImageTypeSpecifier)) {
|
1058 * <code>BufferedImage</code>.
1059 *
1060 * @return a new <code>BufferedImage</code>
1061 *
1062 * @exception IllegalArgumentException if either <code>width</code> or
1063 * <code>height</code> are negative or zero.
1064 * @exception IllegalArgumentException if the product of
1065 * <code>width</code> and <code>height</code> is greater than
1066 * <code>Integer.MAX_VALUE</code>, or if the number of array
1067 * elements needed to store the image is greater than
1068 * <code>Integer.MAX_VALUE</code>.
1069 */
1070 public BufferedImage createBufferedImage(int width, int height) {
1071 try {
1072 SampleModel sampleModel = getSampleModel(width, height);
1073 WritableRaster raster =
1074 Raster.createWritableRaster(sampleModel,
1075 new Point(0, 0));
1076 return new BufferedImage(colorModel, raster,
1077 colorModel.isAlphaPremultiplied(),
1078 new Hashtable<>());
1079 } catch (NegativeArraySizeException e) {
1080 // Exception most likely thrown from a DataBuffer constructor
1081 throw new IllegalArgumentException
1082 ("Array size > Integer.MAX_VALUE!");
1083 }
1084 }
1085
1086 /**
1087 * Returns <code>true</code> if the given <code>Object</code> is
1088 * an <code>ImageTypeSpecifier</code> and has a
1089 * <code>SampleModel</code> and <code>ColorModel</code> that are
1090 * equal to those of this object.
1091 *
1092 * @param o the <code>Object</code> to be compared for equality.
1093 *
1094 * @return <code>true</code> if the given object is an equivalent
1095 * <code>ImageTypeSpecifier</code>.
1096 */
1097 public boolean equals(Object o) {
1098 if ((o == null) || !(o instanceof ImageTypeSpecifier)) {
|