org.jpedal.parser.image.OneBitImage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of OpenViewerFX Show documentation
Show all versions of OpenViewerFX Show documentation
Open Source (LGPL) JavaFX PDF Viewer for NetBeans plugin
/*
* ===========================================
* Java Pdf Extraction Decoding Access Library
* ===========================================
*
* Project Info: http://www.idrsolutions.com
* Help section for developers at http://www.idrsolutions.com/support/
*
* (C) Copyright 1997-2017 IDRsolutions and Contributors.
*
* This file is part of JPedal/JPDF2HTML5
*
@LICENSE@
*
* ---------------
* OneBitImage.java
* ---------------
*/
package org.jpedal.parser.image;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
import java.awt.image.Raster;
import org.jpedal.io.ColorSpaceConvertor;
import org.jpedal.utils.LogWriter;
/**
* @author markee
*/
class OneBitImage {
static BufferedImage make(final int d, final int w, final int h, byte[] data) throws RuntimeException {
LogWriter.writeLog("comp=1 and d= " + d);
final BufferedImage image;
data = ColorSpaceConvertor.normaliseTo8Bit(d, w, h, data);
// create an image from the raw data
final DataBuffer db = new DataBufferByte(data, data.length);
final int[] bands = {0};
image = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_GRAY);
final Raster raster = Raster.createInterleavedRaster(db, w, h, w, 1, bands, null);
image.setData(raster);
return image;
}
}