Search in sources :

Example 1 with ImageLineSetDefault

use of ar.com.hjg.pngj.ImageLineSetDefault in project J2ME-Loader by nikita36078.

the class PNGUtils method fixPNG.

private static Bitmap fixPNG(InputStream stream) throws IOException {
    PngReaderInt reader = new PngReaderInt(stream);
    reader.setCrcCheckDisabled();
    ImageInfo imageInfo = reader.imgInfo;
    int width = imageInfo.cols;
    int height = imageInfo.rows;
    PngChunkTRNS trns = reader.getMetadata().getTRNS();
    PngChunkPLTE plte = reader.getMetadata().getPLTE();
    ImageLineSetDefault<ImageLineInt> lineSet = (ImageLineSetDefault) reader.readRows();
    int[] pix = new int[width * height];
    int[] buf = new int[width];
    for (int i = 0; i < height; i++) {
        ImageLineInt lineInt = lineSet.getImageLine(i);
        ImageLineHelper.scaleUp(lineInt);
        int[] r = lineToARGB32(lineInt, plte, trns, buf);
        for (int j = 0; j < width; j++) {
            pix[i * width + j] = r[j];
        }
    }
    reader.end();
    return Bitmap.createBitmap(pix, width, height, Bitmap.Config.ARGB_8888);
}
Also used : ImageLineSetDefault(ar.com.hjg.pngj.ImageLineSetDefault) PngChunkTRNS(ar.com.hjg.pngj.chunks.PngChunkTRNS) ImageInfo(ar.com.hjg.pngj.ImageInfo) PngChunkPLTE(ar.com.hjg.pngj.chunks.PngChunkPLTE) PngReaderInt(ar.com.hjg.pngj.PngReaderInt) ImageLineInt(ar.com.hjg.pngj.ImageLineInt)

Aggregations

ImageInfo (ar.com.hjg.pngj.ImageInfo)1 ImageLineInt (ar.com.hjg.pngj.ImageLineInt)1 ImageLineSetDefault (ar.com.hjg.pngj.ImageLineSetDefault)1 PngReaderInt (ar.com.hjg.pngj.PngReaderInt)1 PngChunkPLTE (ar.com.hjg.pngj.chunks.PngChunkPLTE)1 PngChunkTRNS (ar.com.hjg.pngj.chunks.PngChunkTRNS)1