Skip to content

Commit 0d08cbc

Browse files
author
Maruan Sahyoun
committed
PDFBOX-5660: simplify
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1932969 13f79535-47bb-0310-9956-ffa450edef68
1 parent 6b083ff commit 0d08cbc

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PNGConverter.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -144,27 +144,27 @@ private static PDImageXObject convertPng(PDDocument doc, PNGConverterState state
144144

145145
if (bitDepth != 1 && bitDepth != 2 && bitDepth != 4 && bitDepth != 8 && bitDepth != 16)
146146
{
147-
LOG.error(String.format("Invalid bit depth %d.", bitDepth));
147+
LOG.error("Invalid bit depth %d.", bitDepth);
148148
return null;
149149
}
150150
if (width <= 0 || height <= 0)
151151
{
152-
LOG.error(String.format("Invalid image size %d x %d", width, height));
152+
LOG.error("Invalid image size %d x %d", width, height);
153153
return null;
154154
}
155155
if (compressionMethod != 0)
156156
{
157-
LOG.error(String.format("Unknown PNG compression method %d.", compressionMethod));
157+
LOG.error("Unknown PNG compression method %d.", compressionMethod);
158158
return null;
159159
}
160160
if (filterMethod != 0)
161161
{
162-
LOG.error(String.format("Unknown PNG filtering method %d.", compressionMethod));
162+
LOG.error("Unknown PNG filtering method %d.", compressionMethod);
163163
return null;
164164
}
165165
if (interlaceMethod != 0)
166166
{
167-
LOG.debug(String.format("Can't handle interlace method %d.", interlaceMethod));
167+
LOG.debug("Can't handle interlace method %d.", interlaceMethod);
168168
return null;
169169
}
170170

@@ -224,8 +224,8 @@ private static PDImageXObject buildIndexImage(PDDocument doc, PNGConverterState
224224
}
225225
if (state.bitsPerComponent > 8)
226226
{
227-
LOG.debug(String.format("Can only convert indexed images with bit depth <= 8, not %d.",
228-
state.bitsPerComponent));
227+
LOG.debug("Can only convert indexed images with bit depth <= 8, not %d.",
228+
state.bitsPerComponent);
229229
return null;
230230
}
231231

@@ -238,8 +238,8 @@ private static PDImageXObject buildIndexImage(PDDocument doc, PNGConverterState
238238
int highVal = (plte.length / 3) - 1;
239239
if (highVal > 255)
240240
{
241-
LOG.error(String.format("Too much colors in PLTE, only 256 allowed, found %d colors.",
242-
highVal + 1));
241+
LOG.error("Too much colors in PLTE, only 256 allowed, found %d colors.",
242+
highVal + 1);
243243
return null;
244244
}
245245

@@ -356,7 +356,7 @@ private static PDImageXObject buildImageObject(PDDocument document, PNGConverter
356356
// The gamma is stored as 1 / gamma.
357357
if (Math.abs(gamma - (1 / 2.2f)) > 0.00001)
358358
{
359-
LOG.debug(String.format("We can't handle gamma of %f yet.", gamma));
359+
LOG.debug("We can't handle gamma of %f yet.", gamma);
360360
return null;
361361
}
362362
}
@@ -365,8 +365,7 @@ private static PDImageXObject buildImageObject(PDDocument document, PNGConverter
365365
{
366366
if (state.sRGB.length != 1)
367367
{
368-
LOG.error(
369-
String.format("sRGB chunk has an invalid length of %d", state.sRGB.length));
368+
LOG.error("sRGB chunk has an invalid length of %d", state.sRGB.length);
370369
return null;
371370
}
372371

@@ -436,8 +435,7 @@ private static PDImageXObject buildImageObject(PDDocument document, PNGConverter
436435
byte compressionMethod = state.iCCP.bytes[state.iCCP.start + iccProfileDataStart];
437436
if (compressionMethod != 0)
438437
{
439-
LOG.error(String.format("iCCP chunk: invalid compression method %d",
440-
compressionMethod));
438+
LOG.error("iCCP chunk: invalid compression method %d", compressionMethod);
441439
return null;
442440
}
443441
// Skip over the compression method
@@ -674,8 +672,7 @@ static boolean checkChunkSane(Chunk chunk)
674672
int ourCRC = crc(chunk.bytes, chunk.start - 4, chunk.length + 4);
675673
if (ourCRC != chunk.crc)
676674
{
677-
LOG.error(String.format("Invalid CRC %08X on chunk %08X, expected %08X.", ourCRC,
678-
chunk.chunkType, chunk.crc));
675+
LOG.error("Invalid CRC %08X on chunk %08X, expected %08X.", ourCRC, chunk.chunkType, chunk.crc);
679676
return false;
680677
}
681678
return true;
@@ -777,7 +774,7 @@ private static PNGConverterState parsePNGChunks(byte[] imageData)
777774

778775
if (firstChunkType != CHUNK_IHDR)
779776
{
780-
LOG.error(String.format("First Chunktype was %08X, not IHDR", firstChunkType));
777+
LOG.error("First Chunktype was %08X, not IHDR", firstChunkType);
781778
return null;
782779
}
783780

@@ -878,7 +875,7 @@ private static PNGConverterState parsePNGChunks(byte[] imageData)
878875
// We don't need the last image change time either
879876
break;
880877
default:
881-
LOG.debug(String.format("Unknown chunk type %08X, skipping.", chunkType));
878+
LOG.debug("Unknown chunk type %08X, skipping.", chunkType);
882879
break;
883880
}
884881
ptr += chunkLength;

0 commit comments

Comments
 (0)