237 public ArrayList<Integer> zTXt_compressionMethod = new ArrayList<Integer>();
238 public ArrayList<String> zTXt_text = new ArrayList<String>();
239
240 // Unknown chunks
241 public ArrayList<String> unknownChunkType = new ArrayList<String>();
242 public ArrayList<byte[]> unknownChunkData = new ArrayList<byte[]>();
243
244 public PNGMetadata() {
245 super(true,
246 nativeMetadataFormatName,
247 nativeMetadataFormatClassName,
248 null, null);
249 }
250
251 public PNGMetadata(IIOMetadata metadata) {
252 // TODO -- implement
253 }
254
255 /**
256 * Sets the IHDR_bitDepth and IHDR_colorType variables.
257 * The <code>numBands</code> parameter is necessary since
258 * we may only be writing a subset of the image bands.
259 */
260 public void initialize(ImageTypeSpecifier imageType, int numBands) {
261 ColorModel colorModel = imageType.getColorModel();
262 SampleModel sampleModel = imageType.getSampleModel();
263
264 // Initialize IHDR_bitDepth
265 int[] sampleSize = sampleModel.getSampleSize();
266 int bitDepth = sampleSize[0];
267 // Choose max bit depth over all channels
268 // Fixes bug 4413109
269 for (int i = 1; i < sampleSize.length; i++) {
270 if (sampleSize[i] > bitDepth) {
271 bitDepth = sampleSize[i];
272 }
273 }
274 // Multi-channel images must have a bit depth of 8 or 16
275 if (sampleSize.length > 1 && bitDepth < 8) {
276 bitDepth = 8;
277 }
|
237 public ArrayList<Integer> zTXt_compressionMethod = new ArrayList<Integer>();
238 public ArrayList<String> zTXt_text = new ArrayList<String>();
239
240 // Unknown chunks
241 public ArrayList<String> unknownChunkType = new ArrayList<String>();
242 public ArrayList<byte[]> unknownChunkData = new ArrayList<byte[]>();
243
244 public PNGMetadata() {
245 super(true,
246 nativeMetadataFormatName,
247 nativeMetadataFormatClassName,
248 null, null);
249 }
250
251 public PNGMetadata(IIOMetadata metadata) {
252 // TODO -- implement
253 }
254
255 /**
256 * Sets the IHDR_bitDepth and IHDR_colorType variables.
257 * The {@code numBands} parameter is necessary since
258 * we may only be writing a subset of the image bands.
259 */
260 public void initialize(ImageTypeSpecifier imageType, int numBands) {
261 ColorModel colorModel = imageType.getColorModel();
262 SampleModel sampleModel = imageType.getSampleModel();
263
264 // Initialize IHDR_bitDepth
265 int[] sampleSize = sampleModel.getSampleSize();
266 int bitDepth = sampleSize[0];
267 // Choose max bit depth over all channels
268 // Fixes bug 4413109
269 for (int i = 1; i < sampleSize.length; i++) {
270 if (sampleSize[i] > bitDepth) {
271 bitDepth = sampleSize[i];
272 }
273 }
274 // Multi-channel images must have a bit depth of 8 or 16
275 if (sampleSize.length > 1 && bitDepth < 8) {
276 bitDepth = 8;
277 }
|