@@ -57,7 +57,7 @@ This file is part of the iText (R) project.
57
57
import java .util .Arrays ;
58
58
import java .util .List ;
59
59
60
- public final class ImageFactory {
60
+ public final class ImageDataFactory {
61
61
62
62
private static final byte [] gif = new byte []{'G' , 'I' , 'F' };
63
63
private static final byte [] jpeg = new byte []{(byte ) 0xFF , (byte ) 0xD8 };
@@ -70,33 +70,33 @@ public final class ImageFactory {
70
70
private static final byte [] tiff_2 = new byte []{'I' , 'I' , 42 , 0 };
71
71
private static final byte [] jbig2 = new byte []{(byte ) 0x97 , 'J' , 'B' , '2' , '\r' , '\n' , 0x1a , '\n' };
72
72
73
- public static ImageData getImage (byte [] bytes , boolean recoverImage ) {
74
- return getImageInstance (bytes , recoverImage );
73
+ public static ImageData create (byte [] bytes , boolean recoverImage ) {
74
+ return createImageInstance (bytes , recoverImage );
75
75
}
76
76
77
- public static ImageData getImage (byte [] bytes ) {
78
- return getImage (bytes , false );
77
+ public static ImageData create (byte [] bytes ) {
78
+ return create (bytes , false );
79
79
}
80
80
81
- public static ImageData getImage (URL url , boolean recoverImage ) {
82
- return getImageInstance (url , recoverImage );
81
+ public static ImageData create (URL url , boolean recoverImage ) {
82
+ return createImageInstance (url , recoverImage );
83
83
}
84
84
85
- public static ImageData getImage (URL url ) {
86
- return getImage (url , false );
85
+ public static ImageData create (URL url ) {
86
+ return create (url , false );
87
87
}
88
88
89
- public static ImageData getImage (String filename , boolean recoverImage ) throws MalformedURLException {
90
- return getImage (UrlUtil .toURL (filename ), recoverImage );
89
+ public static ImageData create (String filename , boolean recoverImage ) throws MalformedURLException {
90
+ return create (UrlUtil .toURL (filename ), recoverImage );
91
91
}
92
92
93
- public static ImageData getImage (String filename ) throws MalformedURLException {
94
- return getImage (filename , false );
93
+ public static ImageData create (String filename ) throws MalformedURLException {
94
+ return create (filename , false );
95
95
}
96
96
97
- public static ImageData getImage (int width , int height , boolean reverseBits ,
98
- int typeCCITT , int parameters , byte [] data ,
99
- int [] transparency ) {
97
+ public static ImageData create (int width , int height , boolean reverseBits ,
98
+ int typeCCITT , int parameters , byte [] data ,
99
+ int [] transparency ) {
100
100
if (transparency != null && transparency .length != 2 )
101
101
throw new IOException (IOException .TransparencyLengthMustBeEqualTo2WithCcittImages );
102
102
if (typeCCITT != RawImageData .CCITTG4 && typeCCITT != RawImageData .CCITTG3_1D && typeCCITT != RawImageData .CCITTG3_2D )
@@ -112,13 +112,13 @@ public static ImageData getImage(int width, int height, boolean reverseBits,
112
112
return image ;
113
113
}
114
114
115
- public static ImageData getImage (int width , int height , int components ,
116
- int bpc , byte [] data , int [] transparency ) {
115
+ public static ImageData create (int width , int height , int components ,
116
+ int bpc , byte [] data , int [] transparency ) {
117
117
if (transparency != null && transparency .length != components * 2 )
118
118
throw new IOException (IOException .TransparencyLengthMustBeEqualTo2WithCcittImages );
119
119
if (components == 1 && bpc == 1 ) {
120
120
byte [] g4 = CCITTG4Encoder .compress (data , width , height );
121
- return ImageFactory . getImage (width , height , false , RawImageData .CCITTG4 , RawImageData .CCITT_BLACKIS1 , g4 , transparency );
121
+ return ImageDataFactory . create (width , height , false , RawImageData .CCITTG4 , RawImageData .CCITT_BLACKIS1 , g4 , transparency );
122
122
}
123
123
RawImageData image = new RawImageData (data , ImageType .RAW );
124
124
image .height = height ;
@@ -141,8 +141,8 @@ public static ImageData getImage(int width, int height, int components,
141
141
* @param color if different from <CODE>null</CODE> the transparency pixels are replaced by this color
142
142
* @return RawImage
143
143
*/
144
- public static ImageData getImage (java .awt .Image image , java .awt .Color color ) throws java .io .IOException {
145
- return ImageFactory . getImage (image , color , false );
144
+ public static ImageData create (java .awt .Image image , java .awt .Color color ) throws java .io .IOException {
145
+ return ImageDataFactory . create (image , color , false );
146
146
}
147
147
148
148
/**
@@ -153,11 +153,11 @@ public static ImageData getImage(java.awt.Image image, java.awt.Color color) thr
153
153
* @param forceBW if <CODE>true</CODE> the image is treated as black and white
154
154
* @return RawImage
155
155
*/
156
- public static ImageData getImage (java .awt .Image image , java .awt .Color color , boolean forceBW ) throws java .io .IOException {
156
+ public static ImageData create (java .awt .Image image , java .awt .Color color , boolean forceBW ) throws java .io .IOException {
157
157
return AwtImageFactory .getImage (image , color , forceBW );
158
158
}
159
159
160
- public static ImageData getBmpImage (URL url , boolean noHeader , int size ) {
160
+ public static ImageData createBmp (URL url , boolean noHeader , int size ) {
161
161
byte [] imageType = readImageType (url );
162
162
if (imageTypeIs (imageType , bmp )) {
163
163
ImageData image = new BmpImageData (url , noHeader , size );
@@ -167,7 +167,7 @@ public static ImageData getBmpImage(URL url, boolean noHeader, int size) {
167
167
throw new IllegalArgumentException ("BMP image expected." );
168
168
}
169
169
170
- public static ImageData getBmpImage (byte [] bytes , boolean noHeader , int size ) {
170
+ public static ImageData createBmp (byte [] bytes , boolean noHeader , int size ) {
171
171
byte [] imageType = readImageType (bytes );
172
172
if (noHeader || imageTypeIs (imageType , bmp )) {
173
173
ImageData image = new BmpImageData (bytes , noHeader , size );
@@ -183,7 +183,7 @@ public static ImageData getBmpImage(byte[] bytes, boolean noHeader, int size) {
183
183
* @param bytes
184
184
* @return
185
185
*/
186
- public static GifImageData getGifImage (byte [] bytes ) {
186
+ public static GifImageData createGif (byte [] bytes ) {
187
187
byte [] imageType = readImageType (bytes );
188
188
if (imageTypeIs (imageType , gif )) {
189
189
GifImageData image = new GifImageData (bytes );
@@ -200,7 +200,7 @@ public static GifImageData getGifImage(byte[] bytes) {
200
200
* @param frame number of frame to be returned
201
201
* @return
202
202
*/
203
- public static ImageData getGifFrame (URL url , int frame ) {
203
+ public static ImageData createGifFrame (URL url , int frame ) {
204
204
byte [] imageType = readImageType (url );
205
205
if (imageTypeIs (imageType , gif )) {
206
206
GifImageData image = new GifImageData (url );
@@ -217,7 +217,7 @@ public static ImageData getGifFrame(URL url, int frame) {
217
217
* @param frame number of frame to be returned
218
218
* @return
219
219
*/
220
- public static ImageData getGifFrame (byte [] bytes , int frame ) {
220
+ public static ImageData createGifFrame (byte [] bytes , int frame ) {
221
221
byte [] imageType = readImageType (bytes );
222
222
if (imageTypeIs (imageType , gif )) {
223
223
GifImageData image = new GifImageData (bytes );
@@ -234,7 +234,7 @@ public static ImageData getGifFrame(byte[] bytes, int frame) {
234
234
* @param frameNumbers array of frame numbers of gif image
235
235
* @return
236
236
*/
237
- public static List <ImageData > getGifFrames (byte [] bytes , int [] frameNumbers ) {
237
+ public static List <ImageData > createGifFrames (byte [] bytes , int [] frameNumbers ) {
238
238
byte [] imageType = readImageType (bytes );
239
239
if (imageTypeIs (imageType , gif )) {
240
240
GifImageData image = new GifImageData (bytes );
@@ -256,7 +256,7 @@ public static List<ImageData> getGifFrames(byte[] bytes, int[] frameNumbers) {
256
256
* @param frameNumbers array of frame numbers of gif image
257
257
* @return
258
258
*/
259
- public static List <ImageData > getGifFrames (URL url , int [] frameNumbers ) {
259
+ public static List <ImageData > createGifFrames (URL url , int [] frameNumbers ) {
260
260
byte [] imageType = readImageType (url );
261
261
if (imageTypeIs (imageType , gif )) {
262
262
GifImageData image = new GifImageData (url );
@@ -277,7 +277,7 @@ public static List<ImageData> getGifFrames(URL url, int[] frameNumbers) {
277
277
* @param bytes byte array of gif image
278
278
* @return all frames of gif image
279
279
*/
280
- public static List <ImageData > getGifFrames (byte [] bytes ) {
280
+ public static List <ImageData > createGifFrames (byte [] bytes ) {
281
281
byte [] imageType = readImageType (bytes );
282
282
if (imageTypeIs (imageType , gif )) {
283
283
GifImageData image = new GifImageData (bytes );
@@ -293,7 +293,7 @@ public static List<ImageData> getGifFrames(byte[] bytes) {
293
293
* @param url url of gif image
294
294
* @return all frames of gif image
295
295
*/
296
- public static List <ImageData > getGifFrames (URL url ) {
296
+ public static List <ImageData > createGifFrames (URL url ) {
297
297
byte [] imageType = readImageType (url );
298
298
if (imageTypeIs (imageType , gif )) {
299
299
GifImageData image = new GifImageData (url );
@@ -303,7 +303,7 @@ public static List<ImageData> getGifFrames(URL url) {
303
303
throw new IllegalArgumentException ("GIF image expected." );
304
304
}
305
305
306
- public static ImageData getJbig2Image (URL url , int page ) {
306
+ public static ImageData createJbig2 (URL url , int page ) {
307
307
if (page < 1 )
308
308
throw new IllegalArgumentException ("The page number must be greater than 0" );
309
309
byte [] imageType = readImageType (url );
@@ -315,7 +315,7 @@ public static ImageData getJbig2Image(URL url, int page) {
315
315
throw new IllegalArgumentException ("JBIG2 image expected." );
316
316
}
317
317
318
- public static ImageData getJbig2Image (byte [] bytes , int page ) {
318
+ public static ImageData createJbig2 (byte [] bytes , int page ) {
319
319
if (page < 1 )
320
320
throw new IllegalArgumentException ("The page number must be greater than 0" );
321
321
byte [] imageType = readImageType (bytes );
@@ -328,7 +328,7 @@ public static ImageData getJbig2Image(byte[] bytes, int page) {
328
328
329
329
}
330
330
331
- public static ImageData getJpegImage (URL url ) {
331
+ public static ImageData createJpeg (URL url ) {
332
332
byte [] imageType = readImageType (url );
333
333
if (imageTypeIs (imageType , jpeg )) {
334
334
ImageData image = new JpegImageData (url );
@@ -338,7 +338,7 @@ public static ImageData getJpegImage(URL url) {
338
338
throw new IllegalArgumentException ("JPEG image expected." );
339
339
}
340
340
341
- public static ImageData getJpegImage (byte [] bytes ) {
341
+ public static ImageData createJpeg (byte [] bytes ) {
342
342
byte [] imageType = readImageType (bytes );
343
343
if (imageTypeIs (imageType , jpeg )) {
344
344
ImageData image = new JpegImageData (bytes );
@@ -349,7 +349,7 @@ public static ImageData getJpegImage(byte[] bytes) {
349
349
350
350
}
351
351
352
- public static ImageData getJpeg2000Image (URL url ) {
352
+ public static ImageData createJpeg2000 (URL url ) {
353
353
byte [] imageType = readImageType (url );
354
354
if (imageTypeIs (imageType , jpeg2000_1 ) || imageTypeIs (imageType , jpeg2000_2 )) {
355
355
ImageData image = new Jpeg2000ImageData (url );
@@ -359,7 +359,7 @@ public static ImageData getJpeg2000Image(URL url) {
359
359
throw new IllegalArgumentException ("JPEG2000 image expected." );
360
360
}
361
361
362
- public static ImageData getJpeg2000Image (byte [] bytes ) {
362
+ public static ImageData createJpeg2000 (byte [] bytes ) {
363
363
byte [] imageType = readImageType (bytes );
364
364
if (imageTypeIs (imageType , jpeg2000_1 ) || imageTypeIs (imageType , jpeg2000_2 )) {
365
365
ImageData image = new Jpeg2000ImageData (bytes );
@@ -370,7 +370,7 @@ public static ImageData getJpeg2000Image(byte[] bytes) {
370
370
371
371
}
372
372
373
- public static ImageData getPngImage (URL url ) {
373
+ public static ImageData createPng (URL url ) {
374
374
byte [] imageType = readImageType (url );
375
375
if (imageTypeIs (imageType , png )) {
376
376
ImageData image = new PngImageData (url );
@@ -380,7 +380,7 @@ public static ImageData getPngImage(URL url) {
380
380
throw new IllegalArgumentException ("PNG image expected." );
381
381
}
382
382
383
- public static ImageData getPngImage (byte [] bytes ) {
383
+ public static ImageData createPng (byte [] bytes ) {
384
384
byte [] imageType = readImageType (bytes );
385
385
if (imageTypeIs (imageType , png )) {
386
386
ImageData image = new PngImageData (bytes );
@@ -390,7 +390,7 @@ public static ImageData getPngImage(byte[] bytes) {
390
390
throw new IllegalArgumentException ("PNG image expected." );
391
391
}
392
392
393
- public static ImageData getTiffImage (URL url , boolean recoverFromImageError , int page , boolean direct ) {
393
+ public static ImageData createTiff (URL url , boolean recoverFromImageError , int page , boolean direct ) {
394
394
byte [] imageType = readImageType (url );
395
395
if (imageTypeIs (imageType , tiff_1 ) || imageTypeIs (imageType , tiff_2 )) {
396
396
ImageData image = new TiffImageData (url , recoverFromImageError , page , direct );
@@ -400,7 +400,7 @@ public static ImageData getTiffImage(URL url, boolean recoverFromImageError, int
400
400
throw new IllegalArgumentException ("TIFF image expected." );
401
401
}
402
402
403
- public static ImageData getTiffImage (byte [] bytes , boolean recoverFromImageError , int page , boolean direct ) {
403
+ public static ImageData createTiff (byte [] bytes , boolean recoverFromImageError , int page , boolean direct ) {
404
404
byte [] imageType = readImageType (bytes );
405
405
if (imageTypeIs (imageType , tiff_1 ) || imageTypeIs (imageType , tiff_2 )) {
406
406
ImageData image = new TiffImageData (bytes , recoverFromImageError , page , direct );
@@ -410,11 +410,11 @@ public static ImageData getTiffImage(byte[] bytes, boolean recoverFromImageError
410
410
throw new IllegalArgumentException ("TIFF image expected." );
411
411
}
412
412
413
- public static ImageData getRawImage (byte [] bytes ) {
413
+ public static ImageData createRawImage (byte [] bytes ) {
414
414
return new RawImageData (bytes , ImageType .RAW );
415
415
}
416
416
417
- private static ImageData getImageInstance (URL source , boolean recoverImage ) {
417
+ private static ImageData createImageInstance (URL source , boolean recoverImage ) {
418
418
byte [] imageType = readImageType (source );
419
419
if (imageTypeIs (imageType , gif )) {
420
420
GifImageData image = new GifImageData (source );
@@ -448,7 +448,7 @@ private static ImageData getImageInstance(URL source, boolean recoverImage) {
448
448
throw new IOException (IOException .ImageFormatCannotBeRecognized );
449
449
}
450
450
451
- private static ImageData getImageInstance (byte [] bytes , boolean recoverImage ) {
451
+ private static ImageData createImageInstance (byte [] bytes , boolean recoverImage ) {
452
452
byte [] imageType = readImageType (bytes );
453
453
if (imageTypeIs (imageType , gif )) {
454
454
GifImageData image = new GifImageData (bytes );
0 commit comments