35 * @author shura 36 */ 37 public class PNGSaver { 38 39 /** 40 * black and white image mode. 41 */ 42 public static final byte BW_MODE = 0; 43 /** 44 * grey scale image mode. 45 */ 46 public static final byte GREYSCALE_MODE = 1; 47 /** 48 * full color image mode. 49 */ 50 public static final byte COLOR_MODE = 2; 51 OutputStream out; 52 CRC32 crc; 53 byte mode; 54 55 /** 56 * 57 * @param file 58 * @throws java.io.FileNotFoundException 59 */ 60 public PNGSaver(File file) throws FileNotFoundException { 61 this(new FileOutputStream(file)); 62 } 63 64 /** 65 * public constructor of PNGEncoder class with greyscale mode by default. 66 * 67 * @param out output stream for PNG image format to write into 68 */ 69 public PNGSaver(OutputStream out) { 70 this(out, COLOR_MODE); 71 } 72 73 /** 74 * public constructor of PNGEncoder class. 75 * 76 * @param out output stream for PNG image format to write into 77 * @param mode BW_MODE, GREYSCALE_MODE or COLOR_MODE 78 */ 79 public PNGSaver(OutputStream out, byte mode) { | 35 * @author shura 36 */ 37 public class PNGSaver { 38 39 /** 40 * black and white image mode. 41 */ 42 public static final byte BW_MODE = 0; 43 /** 44 * grey scale image mode. 45 */ 46 public static final byte GREYSCALE_MODE = 1; 47 /** 48 * full color image mode. 49 */ 50 public static final byte COLOR_MODE = 2; 51 OutputStream out; 52 CRC32 crc; 53 byte mode; 54 55 public PNGSaver(File file) throws FileNotFoundException { 56 this(new FileOutputStream(file)); 57 } 58 59 /** 60 * public constructor of PNGEncoder class with greyscale mode by default. 61 * 62 * @param out output stream for PNG image format to write into 63 */ 64 public PNGSaver(OutputStream out) { 65 this(out, COLOR_MODE); 66 } 67 68 /** 69 * public constructor of PNGEncoder class. 70 * 71 * @param out output stream for PNG image format to write into 72 * @param mode BW_MODE, GREYSCALE_MODE or COLOR_MODE 73 */ 74 public PNGSaver(OutputStream out, byte mode) { |