-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathImageReader.java
2035 lines (1860 loc) · 63.5 KB
/
ImageReader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ImageReader.java -- Decodes raster images.
Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.imageio;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.MissingResourceException;
import java.util.Set;
import javax.imageio.event.IIOReadProgressListener;
import javax.imageio.event.IIOReadUpdateListener;
import javax.imageio.event.IIOReadWarningListener;
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.stream.ImageInputStream;
/**
* A class for decoding images within the ImageIO framework.
*
* An ImageReader for a given format is instantiated by an
* ImageReaderSpi for that format. ImageReaderSpis are registered
* with the IIORegistry.
*
* The ImageReader API supports reading animated images that may have
* multiple frames; to support such images many methods take an index
* parameter.
*
* Images may also be read in multiple passes, where each successive
* pass increases the level of detail in the destination image.
*/
public abstract class ImageReader
{
private boolean aborted;
/**
* All locales available for localization of warning messages, or
* null if localization is not supported.
*/
protected Locale[] availableLocales = null;
/**
* true if the input source does not require metadata to be read,
* false otherwise.
*/
protected boolean ignoreMetadata = false;
/**
* An ImageInputStream from which image data is read.
*/
protected Object input = null;
/**
* The current locale used to localize warning messages, or null if
* no locale has been set.
*/
protected Locale locale = null;
/**
* The minimum index at which data can be read. Constantly 0 if
* seekForwardOnly is false, always increasing if seekForwardOnly is
* true.
*/
protected int minIndex = 0;
/**
* The image reader SPI that instantiated this reader.
*/
protected ImageReaderSpi originatingProvider = null;
/**
* A list of installed progress listeners. Initially null, meaning
* no installed listeners.
*/
protected List<IIOReadProgressListener> progressListeners = null;
/**
* true if this reader should only read data further ahead in the
* stream than its current location. false if it can read backwards
* in the stream. If this is true then caching can be avoided.
*/
protected boolean seekForwardOnly = false;
/**
* A list of installed update listeners. Initially null, meaning no
* installed listeners.
*/
protected List<IIOReadUpdateListener> updateListeners = null;
/**
* A list of installed warning listeners. Initially null, meaning
* no installed listeners.
*/
protected List<IIOReadWarningListener> warningListeners = null;
/**
* A list of warning locales corresponding with the list of
* installed warning listeners. Initially null, meaning no locales.
*/
protected List<Locale> warningLocales = null;
/**
* Construct an image reader.
*
* @param originatingProvider the provider that is constructing this
* image reader, or null
*/
protected ImageReader(ImageReaderSpi originatingProvider)
{
this.originatingProvider = originatingProvider;
}
/**
* Request that reading be aborted. The unread contents of the
* image will be undefined.
*
* Readers should clear the abort flag before starting a read
* operation, then poll it periodically during the read operation.
*/
public void abort()
{
aborted = true;
}
/**
* Check if the abort flag is set.
*
* @return true if the current read operation should be aborted,
* false otherwise
*/
protected boolean abortRequested()
{
return aborted;
}
/**
* Install a read progress listener. This method will return
* immediately if listener is null.
*
* @param listener a read progress listener or null
*/
public void addIIOReadProgressListener(IIOReadProgressListener listener)
{
if (listener == null)
return;
if (progressListeners == null)
progressListeners = new ArrayList ();
progressListeners.add(listener);
}
/**
* Install a read update listener. This method will return
* immediately if listener is null.
*
* @param listener a read update listener
*/
public void addIIOReadUpdateListener(IIOReadUpdateListener listener)
{
if (listener == null)
return;
if (updateListeners == null)
updateListeners = new ArrayList ();
updateListeners.add(listener);
}
/**
* Install a read warning listener. This method will return
* immediately if listener is null. Warning messages sent to this
* listener will be localized using the current locale. If the
* current locale is null then this reader will select a sensible
* default.
*
* @param listener a read warning listener
*/
public void addIIOReadWarningListener(IIOReadWarningListener listener)
{
if (listener == null)
return;
if (warningListeners == null)
warningListeners = new ArrayList ();
warningListeners.add(listener);
}
/**
* Check if this reader can handle raster data. Determines whether
* or not readRaster and readTileRaster throw
* UnsupportedOperationException.
*
* @return true if this reader supports raster data, false if not
*/
public boolean canReadRaster()
{
return false;
}
/**
* Clear the abort flag.
*/
protected void clearAbortRequest()
{
aborted = false;
}
/**
* Releases any resources allocated to this object. Subsequent
* calls to methods on this object will produce undefined results.
*
* The default implementation does nothing; subclasses should use
* this method ensure that native resources are released.
*/
public void dispose()
{
// The default implementation does nothing.
}
/**
* Returns the aspect ratio of this image, the ration of its width
* to its height. The aspect ratio is useful when resizing an image
* while keeping its proportions constant.
*
* @param imageIndex the frame index
*
* @return the image's aspect ratio
*
* @exception IllegalStateException if input is null
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public float getAspectRatio(int imageIndex)
throws IOException
{
if (input == null)
throw new IllegalStateException("input is null");
return (float) (getWidth(imageIndex) / getHeight(imageIndex));
}
/**
* Retrieve the available locales. Return null if no locales are
* available or a clone of availableLocales.
*
* @return an array of locales or null
*/
public Locale[] getAvailableLocales()
{
if (availableLocales == null)
return null;
return (Locale[]) availableLocales.clone();
}
/**
* Retrieve the default read parameters for this reader's image
* format.
*
* The default implementation returns new ImageReadParam().
*
* @return image reading parameters
*/
public ImageReadParam getDefaultReadParam()
{
return new ImageReadParam();
}
/**
* Retrieve the format of the input source.
*
* @return the input source format name
*
* @exception IOException if a read error occurs
*/
public String getFormatName()
throws IOException
{
return originatingProvider.getFormatNames()[0];
}
/**
* Get the height of the input image in pixels. If the input image
* is resizable then a default height is returned.
*
* @param imageIndex the frame index
*
* @return the height of the input image
*
* @exception IllegalStateException if input has not been set
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public abstract int getHeight(int imageIndex)
throws IOException;
/**
* Get the metadata associated with this image. If the reader is
* set to ignore metadata or does not support reading metadata, or
* if no metadata is available then null is returned.
*
* @param imageIndex the frame index
*
* @return a metadata object, or null
*
* @exception IllegalStateException if input has not been set
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public abstract IIOMetadata getImageMetadata(int imageIndex)
throws IOException;
/**
* Get an iterator over the collection of image types into which
* this reader can decode image data. This method is guaranteed to
* return at least one valid image type specifier.
*
* The elements of the iterator should be ordered; the first element
* should be the most appropriate image type for this decoder,
* followed by the second-most appropriate, and so on.
*
* @param imageIndex the frame index
*
* @return an iterator over a collection of image type specifiers
*
* @exception IllegalStateException if input has not been set
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public abstract Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex)
throws IOException;
/**
* Set the input source to the given object, specify whether this
* reader should be allowed to read input from the data stream more
* than once, and specify whether this reader should ignore metadata
* in the input stream. The input source must be set before many
* methods can be called on this reader. (see all ImageReader
* methods that throw IllegalStateException). If input is null then
* the current input source will be removed.
*
* Unless this reader has direct access with imaging hardware, input
* should be an ImageInputStream.
*
* @param input the input source object
* @param seekForwardOnly true if this reader should be allowed to
* read input from the data stream more than once, false otherwise
* @param ignoreMetadata true if this reader should ignore metadata
* associated with the input source, false otherwise
*
* @exception IllegalArgumentException if input is not a valid input
* source for this reader and is not an ImageInputStream
*/
public void setInput(Object input,
boolean seekForwardOnly,
boolean ignoreMetadata)
{
Class[] okClasses = originatingProvider.getInputTypes();
if (okClasses == null)
{
if (!(input instanceof ImageInputStream))
throw new IllegalArgumentException();
}
else
{
boolean classOk = false;
for (int i = 0; i < okClasses.length; ++i)
if (okClasses[i].isInstance(input))
classOk = true;
if (!classOk)
throw new IllegalArgumentException();
}
this.input = input;
this.seekForwardOnly = seekForwardOnly;
this.ignoreMetadata = ignoreMetadata;
this.minIndex = 0;
}
/**
* Set the input source to the given object and specify whether this
* reader should be allowed to read input from the data stream more
* than once. The input source must be set before many methods can
* be called on this reader. (see all ImageReader methods that throw
* IllegalStateException). If input is null then the current input
* source will be removed.
*
* @param in the input source object
* @param seekForwardOnly true if this reader should be allowed to
* read input from the data stream more than once, false otherwise
*
* @exception IllegalArgumentException if input is not a valid input
* source for this reader and is not an ImageInputStream
*/
public void setInput(Object in, boolean seekForwardOnly)
{
setInput(in, seekForwardOnly, false);
}
/**
* Set the input source to the given object. The input source must
* be set before many methods can be called on this reader. (see all
* ImageReader methods that throw IllegalStateException). If input
* is null then the current input source will be removed.
*
* @param input the input source object
*
* @exception IllegalArgumentException if input is not a valid input
* source for this reader and is not an ImageInputStream
*/
public void setInput(Object input)
{
setInput(input, false, false);
}
/**
* Get this reader's image input source. null is returned if the
* image source has not been set.
*
* @return an image input source object, or null
*/
public Object getInput()
{
return input;
}
/**
* Get this reader's locale. null is returned if the locale has not
* been set.
*
* @return this reader's locale, or null
*/
public Locale getLocale()
{
return locale;
}
/**
* Return the number of images available from the image input
* source, not including thumbnails. This method will return 1
* unless this reader is reading an animated image.
*
* Certain multi-image formats do not encode the total number of
* images. When reading images in those formats it may be necessary
* to repeatedly call read, incrementing the image index at each
* call, until an IndexOutOfBoundsException is thrown.
*
* The allowSearch parameter determines whether all images must be
* available at all times. When allowSearch is false, getNumImages
* will return -1 if the total number of images is unknown.
* Otherwise this method returns the number of images.
*
* @param allowSearch true if all images should be available at
* once, false otherwise
*
* @return -1 if allowSearch is false and the total number of images
* is currently unknown, or the number of images
*
* @exception IllegalStateException if input has not been set, or if
* seekForwardOnly is true
* @exception IOException if a read error occurs
*/
public abstract int getNumImages(boolean allowSearch)
throws IOException;
/**
* Get the number of thumbnails associated with an image.
*
* @param imageIndex the frame index
*
* @return the number of thumbnails associated with this image
*/
public int getNumThumbnails(int imageIndex)
throws IOException
{
return 0;
}
/**
* Get the ImageReaderSpi that created this reader or null.
*
* @return an ImageReaderSpi, or null
*/
public ImageReaderSpi getOriginatingProvider()
{
return originatingProvider;
}
/**
* Get the metadata associated with the image being read. If the
* reader is set to ignore metadata or does not support reading
* metadata, or if no metadata is available then null is returned.
* This method returns metadata associated with the entirety of the
* image data, whereas getImageMetadata(int) returns metadata
* associated with a frame within a multi-image data stream.
*
* @return metadata associated with the image being read, or null
*
* @exception IOException if a read error occurs
*/
public abstract IIOMetadata getStreamMetadata()
throws IOException;
/**
* Get the height of a thumbnail image.
*
* @param imageIndex the frame index
* @param thumbnailIndex the thumbnail index
*
* @return the height of the thumbnail image
*
* @exception UnsupportedOperationException if this reader does not
* support thumbnails
* @exception IllegalStateException if input is null
* @exception IndexOutOfBoundsException if either index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public int getThumbnailHeight(int imageIndex, int thumbnailIndex)
throws IOException
{
return readThumbnail(imageIndex, thumbnailIndex).getHeight();
}
/**
* Get the width of a thumbnail image.
*
* @param imageIndex the frame index
* @param thumbnailIndex the thumbnail index
*
* @return the width of the thumbnail image
*
* @exception UnsupportedOperationException if this reader does not
* support thumbnails
* @exception IllegalStateException if input is null
* @exception IndexOutOfBoundsException if either index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public int getThumbnailWidth(int imageIndex, int thumbnailIndex)
throws IOException
{
return readThumbnail(imageIndex, thumbnailIndex).getWidth();
}
/**
* Get the X coordinate in pixels of the top-left corner of the
* first tile in this image.
*
* @param imageIndex the frame index
*
* @return the X coordinate of this image's first tile
*
* @exception IllegalStateException if input is needed but the input
* source is not set
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public int getTileGridXOffset(int imageIndex)
throws IOException
{
return 0;
}
/**
* Get the Y coordinate in pixels of the top-left corner of the
* first tile in this image.
*
* @param imageIndex the frame index
*
* @return the Y coordinate of this image's first tile
*
* @exception IllegalStateException if input is needed but the input
* source is not set
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public int getTileGridYOffset(int imageIndex)
throws IOException
{
return 0;
}
/**
* Get the height of an image tile.
*
* @param imageIndex the frame index
*
* @return the tile height for the given image
*
* @exception IllegalStateException if input is null
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public int getTileHeight(int imageIndex)
throws IOException
{
return getHeight(imageIndex);
}
/**
* Get the width of an image tile.
*
* @param imageIndex the frame index
*
* @return the tile width for the given image
*
* @exception IllegalStateException if input is null
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public int getTileWidth(int imageIndex)
throws IOException
{
return getWidth(imageIndex);
}
/**
* Get the width of the input image in pixels. If the input image
* is resizable then a default width is returned.
*
* @param imageIndex the image's index
*
* @return the width of the input image
*
* @exception IllegalStateException if input has not been set
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public abstract int getWidth(int imageIndex)
throws IOException;
/**
* Check whether or not the given image has thumbnails associated
* with it.
*
* @return true if the given image has thumbnails, false otherwise
*
* @exception IllegalStateException if input is null
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public boolean hasThumbnails(int imageIndex)
throws IOException
{
return getNumThumbnails(imageIndex) > 0;
}
/**
* Check if this image reader ignores metadata. This method simply
* returns the value of ignoreMetadata.
*
* @return true if metadata is being ignored, false otherwise
*/
public boolean isIgnoringMetadata()
{
return ignoreMetadata;
}
/**
* Check if the given image is sub-divided into equal-sized
* non-overlapping pixel rectangles.
*
* A reader may expose tiling in the underlying format, hide it, or
* simulate tiling even if the underlying format is not tiled.
*
* @return true if the given image is tiled, false otherwise
*
* @exception IllegalStateException if input is null
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds
* @exception IOException if a read error occurs
*/
public boolean isImageTiled(int imageIndex)
throws IOException
{
return false;
}
/**
* Check if all pixels in this image are readily accessible. This
* method should return false for compressed formats. The return
* value is a hint as to the efficiency of certain image reader
* operations.
*
* @param imageIndex the frame index
*
* @return true if random pixel access is fast, false otherwise
*
* @exception IllegalStateException if input is null and it is
* needed to determine the return value
* @exception IndexOutOfBoundsException if the frame index is
* out-of-bounds but the frame data must be accessed to determine
* the return value
* @exception IOException if a read error occurs
*/
public boolean isRandomAccessEasy(int imageIndex)
throws IOException
{
return false;
}
/**
* Check if this image reader may only seek forward within the input
* stream.
*
* @return true if this reader may only seek forward, false
* otherwise
*/
public boolean isSeekForwardOnly()
{
return seekForwardOnly;
}
/**
* Notifies all installed read progress listeners that image loading
* has completed by calling their imageComplete methods.
*/
protected void processImageComplete()
{
if (progressListeners != null)
{
Iterator it = progressListeners.iterator();
while (it.hasNext())
{
IIOReadProgressListener listener =
(IIOReadProgressListener) it.next();
listener.imageComplete (this);
}
}
}
/**
* Notifies all installed read progress listeners that a certain
* percentage of the image has been loaded, by calling their
* imageProgress methods.
*
* @param percentageDone the percentage of image data that has been
* loaded
*/
protected void processImageProgress(float percentageDone)
{
if (progressListeners != null)
{
Iterator it = progressListeners.iterator();
while (it.hasNext())
{
IIOReadProgressListener listener =
(IIOReadProgressListener) it.next();
listener.imageProgress(this, percentageDone);
}
}
}
/**
* Notifies all installed read progress listeners, by calling their
* imageStarted methods, that image loading has started on the given
* image.
*
* @param imageIndex the frame index of the image that has started
* loading
*/
protected void processImageStarted(int imageIndex)
{
if (progressListeners != null)
{
Iterator it = progressListeners.iterator();
while (it.hasNext())
{
IIOReadProgressListener listener =
(IIOReadProgressListener) it.next();
listener.imageStarted(this, imageIndex);
}
}
}
/**
* Notifies all installed read update listeners, by calling their
* imageUpdate methods, that the set of samples has changed.
*
* @param image the buffered image that is being updated
* @param minX the X coordinate of the top-left pixel in this pass
* @param minY the Y coordinate of the top-left pixel in this pass
* @param width the total width of the rectangle covered by this
* pass, including skipped pixels
* @param height the total height of the rectangle covered by this
* pass, including skipped pixels
* @param periodX the horizontal sample interval
* @param periodY the vertical sample interval
* @param bands the affected bands in the destination
*/
protected void processImageUpdate(BufferedImage image, int minX, int minY,
int width, int height, int periodX,
int periodY, int[] bands)
{
if (updateListeners != null)
{
Iterator it = updateListeners.iterator();
while (it.hasNext())
{
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
listener.imageUpdate(this, image, minX, minY, width, height,
periodX, periodY, bands);
}
}
}
/**
* Notifies all installed update progress listeners, by calling
* their passComplete methods, that a progressive pass has
* completed.
*
* @param image the image that has being updated
*/
protected void processPassComplete(BufferedImage image)
{
if (updateListeners != null)
{
Iterator it = updateListeners.iterator();
while (it.hasNext())
{
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
listener.passComplete(this, image);
}
}
}
/**
* Notifies all installed read update listeners, by calling their
* passStarted methods, that a new pass has begun.
*
* @param image the buffered image that is being updated
* @param pass the current pass number
* @param minPass the pass at which decoding will begin
* @param maxPass the pass at which decoding will end
* @param minX the X coordinate of the top-left pixel in this pass
* @param minY the Y coordinate of the top-left pixel in this pass
* @param width the total width of the rectangle covered by this
* pass, including skipped pixels
* @param height the total height of the rectangle covered by this
* pass, including skipped pixels
* @param periodX the horizontal sample interval
* @param periodY the vertical sample interval
* @param bands the affected bands in the destination
*/
protected void processPassStarted(BufferedImage image, int pass, int minPass,
int maxPass, int minX, int minY,
int periodX, int periodY, int[] bands)
{
if (updateListeners != null)
{
Iterator it = updateListeners.iterator();
while (it.hasNext())
{
IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
listener.passStarted(this, image, pass, minPass, maxPass, minX,
minY, periodX, periodY, bands);
}
}
}
/**
* Notifies all installed read progress listeners that image loading
* has been aborted by calling their readAborted methods.
*/
protected void processReadAborted()
{
if (progressListeners != null)
{
Iterator it = progressListeners.iterator();
while (it.hasNext())
{
IIOReadProgressListener listener =
(IIOReadProgressListener) it.next();
listener.readAborted(this);
}
}
}
/**
* Notifies all installed read progress listeners, by calling their
* sequenceComplete methods, that a sequence of images has completed
* loading.
*/
protected void processSequenceComplete()
{
if (progressListeners != null)
{
Iterator it = progressListeners.iterator();
while (it.hasNext())
{
IIOReadProgressListener listener =
(IIOReadProgressListener) it.next();
listener.sequenceComplete(this);
}
}
}
/**
* Notifies all installed read progress listeners, by calling their
* sequenceStarted methods, a sequence of images has started
* loading.
*
* @param minIndex the index of the first image in the sequence
*/
protected void processSequenceStarted(int minIndex)
{
if (progressListeners != null)
{
Iterator it = progressListeners.iterator();
while (it.hasNext())
{
IIOReadProgressListener listener =
(IIOReadProgressListener) it.next();
listener.sequenceStarted(this, minIndex);
}
}
}
/**
* Notifies all installed read progress listeners, by calling their
* thumbnailComplete methods, that a thumbnail has completed
* loading.
*/
protected void processThumbnailComplete()
{
if (progressListeners != null)
{
Iterator it = progressListeners.iterator();
while (it.hasNext())
{
IIOReadProgressListener listener =
(IIOReadProgressListener) it.next();
listener.thumbnailComplete(this);
}
}
}
/**
* Notifies all installed update progress listeners, by calling
* their thumbnailPassComplete methods, that a progressive pass has