Mercurial > projects > dwt-mac
comparison dwt/internal/image/TIFFDirectory.d @ 6:b903c16b6f48
Removed throws decls
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 14:10:03 +0200 |
parents | 1a8b3cb347e0 |
children | 5123b17c98ef |
comparison
equal
deleted
inserted
replaced
5:1a8b3cb347e0 | 6:b903c16b6f48 |
---|---|
113 | 113 |
114 int getEntryValue(int type, byte[] buffer, int index) { | 114 int getEntryValue(int type, byte[] buffer, int index) { |
115 return toInt(buffer, index + 8, type); | 115 return toInt(buffer, index + 8, type); |
116 } | 116 } |
117 | 117 |
118 void getEntryValue(int type, byte[] buffer, int index, int[] values) throws IOException { | 118 void getEntryValue(int type, byte[] buffer, int index, int[] values) { |
119 int start = index + 8; | 119 int start = index + 8; |
120 int size; | 120 int size; |
121 int offset = toInt(buffer, start, TYPE_LONG); | 121 int offset = toInt(buffer, start, TYPE_LONG); |
122 switch (type) { | 122 switch (type) { |
123 case TYPE_SHORT: size = 2; break; | 123 case TYPE_SHORT: size = 2; break; |
136 for (int i = 0; i < values.length; i++) { | 136 for (int i = 0; i < values.length; i++) { |
137 values[i] = toInt(buffer, start + i * size, type); | 137 values[i] = toInt(buffer, start + i * size, type); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 void decodePixels(ImageData image) throws IOException { | 141 void decodePixels(ImageData image) { |
142 /* Each row is byte aligned */ | 142 /* Each row is byte aligned */ |
143 byte[] imageData = new byte[(imageWidth * depth + 7) / 8 * imageLength]; | 143 byte[] imageData = new byte[(imageWidth * depth + 7) / 8 * imageLength]; |
144 image.data = imageData; | 144 image.data = imageData; |
145 int destIndex = 0; | 145 int destIndex = 0; |
146 int length = stripOffsets.length; | 146 int length = stripOffsets.length; |
167 loader.notifyListeners(new ImageLoaderEvent(loader, image, i, i is length - 1)); | 167 loader.notifyListeners(new ImageLoaderEvent(loader, image, i, i is length - 1)); |
168 } | 168 } |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 PaletteData getColorMap() throws IOException { | 172 PaletteData getColorMap() { |
173 int numColors = 1 << bitsPerSample[0]; | 173 int numColors = 1 << bitsPerSample[0]; |
174 /* R, G, B entries are 16 bit wide (2 bytes) */ | 174 /* R, G, B entries are 16 bit wide (2 bytes) */ |
175 int numBytes = 3 * 2 * numColors; | 175 int numBytes = 3 * 2 * numColors; |
176 byte[] buffer = new byte[numBytes]; | 176 byte[] buffer = new byte[numBytes]; |
177 file.seek(colorMapOffset); | 177 file.seek(colorMapOffset); |
296 colorMap[i + offsetBlue] = rgbs[i].blue << 8 | rgbs[i].blue; | 296 colorMap[i + offsetBlue] = rgbs[i].blue << 8 | rgbs[i].blue; |
297 } | 297 } |
298 return colorMap; | 298 return colorMap; |
299 } | 299 } |
300 | 300 |
301 void parseEntries(byte[] buffer) throws IOException { | 301 void parseEntries(byte[] buffer) { |
302 for (int offset = 0; offset < buffer.length; offset += IFD_ENTRY_SIZE) { | 302 for (int offset = 0; offset < buffer.length; offset += IFD_ENTRY_SIZE) { |
303 int tag = toInt(buffer, offset, TYPE_SHORT); | 303 int tag = toInt(buffer, offset, TYPE_SHORT); |
304 int type = toInt(buffer, offset + 2, TYPE_SHORT); | 304 int type = toInt(buffer, offset + 2, TYPE_SHORT); |
305 int count = toInt(buffer, offset + 4, TYPE_LONG); | 305 int count = toInt(buffer, offset + 4, TYPE_LONG); |
306 switch (tag) { | 306 switch (tag) { |
377 } | 377 } |
378 } | 378 } |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 public ImageData read() throws IOException { | 382 public ImageData read() { |
383 /* Set TIFF default values */ | 383 /* Set TIFF default values */ |
384 bitsPerSample = new int[] {1}; | 384 bitsPerSample = new int[] {1}; |
385 colorMapOffset = NO_VALUE; | 385 colorMapOffset = NO_VALUE; |
386 compression = 1; | 386 compression = 1; |
387 imageLength = NO_VALUE; | 387 imageLength = NO_VALUE; |
464 /* Invalid type */ | 464 /* Invalid type */ |
465 DWT.error(DWT.ERROR_INVALID_IMAGE); | 465 DWT.error(DWT.ERROR_INVALID_IMAGE); |
466 return -1; | 466 return -1; |
467 } | 467 } |
468 | 468 |
469 void write(int photometricInterpretation) throws IOException { | 469 void write(int photometricInterpretation) { |
470 bool isRGB = photometricInterpretation is 2; | 470 bool isRGB = photometricInterpretation is 2; |
471 bool isColorMap = photometricInterpretation is 3; | 471 bool isColorMap = photometricInterpretation is 3; |
472 bool isBiLevel = photometricInterpretation is 0 || photometricInterpretation is 1; | 472 bool isBiLevel = photometricInterpretation is 0 || photometricInterpretation is 1; |
473 | 473 |
474 int imageWidth = image.width; | 474 int imageWidth = image.width; |
565 | 565 |
566 /* Image Data */ | 566 /* Image Data */ |
567 out.write(data); | 567 out.write(data); |
568 } | 568 } |
569 | 569 |
570 void writeEntry(short tag, int type, int count, int value) throws IOException { | 570 void writeEntry(short tag, int type, int count, int value) { |
571 out.writeShort(tag); | 571 out.writeShort(tag); |
572 out.writeShort(type); | 572 out.writeShort(type); |
573 out.writeInt(count); | 573 out.writeInt(count); |
574 out.writeInt(value); | 574 out.writeInt(value); |
575 } | 575 } |
576 | 576 |
577 void writeHeader() throws IOException { | 577 void writeHeader() { |
578 /* little endian */ | 578 /* little endian */ |
579 out.write(0x49); | 579 out.write(0x49); |
580 out.write(0x49); | 580 out.write(0x49); |
581 | 581 |
582 /* TIFF identifier */ | 582 /* TIFF identifier */ |
586 * It is word aligned and immediately after this header. | 586 * It is word aligned and immediately after this header. |
587 */ | 587 */ |
588 out.writeInt(8); | 588 out.writeInt(8); |
589 } | 589 } |
590 | 590 |
591 void writeToStream(LEDataOutputStream byteStream) throws IOException { | 591 void writeToStream(LEDataOutputStream byteStream) { |
592 out = byteStream; | 592 out = byteStream; |
593 int photometricInterpretation = -1; | 593 int photometricInterpretation = -1; |
594 | 594 |
595 /* Scanline pad must be 1 */ | 595 /* Scanline pad must be 1 */ |
596 if (image.scanlinePad !is 1) DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT); | 596 if (image.scanlinePad !is 1) DWT.error(DWT.ERROR_UNSUPPORTED_FORMAT); |