1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.imaging.common;
19
20 import java.awt.image.BufferedImage;
21
22 public class SimpleBufferedImageFactory implements BufferedImageFactory {
23 @Override
24 public BufferedImage getColorBufferedImage(final int width, final int height, final boolean hasAlpha) {
25 if (hasAlpha) {
26 return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
27 }
28 return new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
29 }
30
31 @Override
32 public BufferedImage getGrayscaleBufferedImage(final int width, final int height, final boolean hasAlpha) {
33 if (hasAlpha) {
34 return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
35 }
36
37 return new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
38 }
39 }