1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.imaging.formats.png;
18
19 import java.awt.image.BufferedImage;
20 import java.io.IOException;
21 import java.io.InputStream;
22
23 import org.apache.commons.imaging.ImagingException;
24 import org.apache.commons.imaging.formats.png.chunks.PngChunkPlte;
25 import org.apache.commons.imaging.formats.png.transparencyfilters.AbstractTransparencyFilter;
26
27 final class ScanExpediterSimple extends AbstractScanExpediter {
28 ScanExpediterSimple(final int width, final int height, final InputStream is, final BufferedImage bi, final PngColorType pngColorType, final int bitDepth,
29 final int bitsPerPixel, final PngChunkPlte pngChunkPLTE, final GammaCorrection gammaCorrection,
30 final AbstractTransparencyFilter abstractTransparencyFilter) {
31 super(width, height, is, bi, pngColorType, bitDepth, bitsPerPixel, pngChunkPLTE, gammaCorrection, abstractTransparencyFilter);
32 }
33
34 @Override
35 public void drive() throws ImagingException, IOException {
36 final int bitsPerScanLine = bitsPerPixel * width;
37 final int pixelBytesPerScanLine = getBitsToBytesRoundingUp(bitsPerScanLine);
38 byte[] prev = null;
39
40 for (int y = 0; y < height; y++) {
41 final byte[] unfiltered = getNextScanline(is, pixelBytesPerScanLine, prev, bytesPerPixel);
42
43 prev = unfiltered;
44
45 final BitParser bitParser = new BitParser(unfiltered, bitsPerPixel, bitDepth);
46
47 for (int x = 0; x < width; x++) {
48 final int rgb = getRgb(bitParser, x);
49
50 bi.setRGB(x, y, rgb);
51 }
52 }
53
54 }
55 }