com.lowagie.text.pdf.codec.CCITTG4Encoder Java Examples

The following examples show how to use com.lowagie.text.pdf.codec.CCITTG4Encoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Image.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Gets an instance of an Image in raw mode.
 *
 * @param width the width of the image in pixels
 * @param height the height of the image in pixels
 * @param components 1,3 or 4 for GrayScale, RGB and CMYK
 * @param data the image data
 * @param bpc bits per component
 * @param transparency transparency information in the Mask format of the image dictionary
 * @return an object of type <CODE>ImgRaw</CODE>
 * @throws BadElementException on error
 */
public static Image getInstance(int width, int height, int components, int bpc, byte data[], int transparency[]) throws BadElementException {
	if (transparency != null && transparency.length != components * 2) {
		throw new BadElementException("Transparency length must be equal to (componentes * 2)");
	}
	if (components == 1 && bpc == 1) {
		byte g4[] = CCITTG4Encoder.compress(data, width, height);
		return Image.getInstance(width, height, false, Element.CCITTG4, Element.CCITT_BLACKIS1, g4, transparency);
	}
	Image img = new ImgRaw(width, height, components, bpc, data);
	img.transparency = transparency;
	return img;
}
 
Example #2
Source File: BarcodeDatamatrix.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Gets an <CODE>Image</CODE> with the barcode. A successful call to the method
 * <CODE>generate()</CODE> before calling this method is required.
 * 
 * @return the barcode <CODE>Image</CODE>
 * @throws BadElementException on error
 */
public Image createImage() throws BadElementException {
	if (image == null) {
		return null;
	}
	byte g4[] = CCITTG4Encoder.compress(image, width + 2 * ws, height + 2 * ws);
	return Image.getInstance(width + 2 * ws, height + 2 * ws, false, Element.CCITTG4, 0, g4, null);
}
 
Example #3
Source File: BarcodeDatamatrix.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Gets an <CODE>Image</CODE> with the barcode. A successful call to the method <CODE>generate()</CODE>
 * before calling this method is required.
 * @return the barcode <CODE>Image</CODE>
 * @throws BadElementException on error
 */    
public Image createImage() throws BadElementException {
    if (image == null)
        return null;
    byte g4[] = CCITTG4Encoder.compress(image, width + 2 * ws, height + 2 * ws);
    return Image.getInstance(width + 2 * ws, height + 2 * ws, false, Image.CCITTG4, 0, g4, null);
}
 
Example #4
Source File: Image.java    From itext2 with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Gets an instance of an Image in raw mode.
 * 
 * @param width
 *            the width of the image in pixels
 * @param height
 *            the height of the image in pixels
 * @param components
 *            1,3 or 4 for GrayScale, RGB and CMYK
 * @param data
 *            the image data
 * @param bpc
 *            bits per component
 * @param transparency
 *            transparency information in the Mask format of the image
 *            dictionary
 * @return an object of type <CODE>ImgRaw</CODE>
 * @throws BadElementException
 *             on error
 */
public static Image getInstance(int width, int height, int components,
		int bpc, byte data[], int transparency[])
		throws BadElementException {
	if (transparency != null && transparency.length != components * 2)
		throw new BadElementException(
				"Transparency length must be equal to (componentes * 2)");
	if (components == 1 && bpc == 1) {
		byte g4[] = CCITTG4Encoder.compress(data, width, height);
		return Image.getInstance(width, height, false, Image.CCITTG4,
				Image.CCITT_BLACKIS1, g4, transparency);
	}
	Image img = new ImgRaw(width, height, components, bpc, data);
	img.transparency = transparency;
	return img;
}
 
Example #5
Source File: Image.java    From MesquiteCore with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Gets an instance of an Image in raw mode.
 * 
 * @param width
 *            the width of the image in pixels
 * @param height
 *            the height of the image in pixels
 * @param components
 *            1,3 or 4 for GrayScale, RGB and CMYK
 * @param data
 *            the image data
 * @param bpc
 *            bits per component
 * @param transparency
 *            transparency information in the Mask format of the image
 *            dictionary
 * @return an object of type <CODE>ImgRaw</CODE>
 * @throws BadElementException
 *             on error
 */

public static Image getInstance(int width, int height, int components,
		int bpc, byte data[], int transparency[])
		throws BadElementException {
	if (transparency != null && transparency.length != components * 2)
		throw new BadElementException(
				"Transparency length must be equal to (componentes * 2)");
	if (components == 1 && bpc == 1) {
		byte g4[] = CCITTG4Encoder.compress(data, width, height);
		return Image.getInstance(width, height, false, Image.CCITTG4,
				Image.CCITT_BLACKIS1, g4, transparency);
	}
	Image img = new ImgRaw(width, height, components, bpc, data);
	img.transparency = transparency;
	return img;
}
 
Example #6
Source File: BarcodePDF417.java    From gcs with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Gets an <CODE>Image</CODE> with the barcode. The image will have to be scaled in the Y
 * direction by <CODE>yHeight</CODE>for the barcode to have the right printing aspect.
 * 
 * @return the barcode <CODE>Image</CODE>
 * @throws BadElementException on error
 */
public Image getImage() throws BadElementException {
	paintCode();
	byte g4[] = CCITTG4Encoder.compress(outBits, bitColumns, codeRows);
	return Image.getInstance(bitColumns, codeRows, false, Element.CCITTG4, (options & PDF417_INVERT_BITMAP) == 0 ? 0 : Element.CCITT_BLACKIS1, g4, null);
}
 
Example #7
Source File: BarcodePDF417.java    From itext2 with GNU Lesser General Public License v3.0 2 votes vote down vote up
/** Gets an <CODE>Image</CODE> with the barcode. The image will have to be
 * scaled in the Y direction by <CODE>yHeight</CODE>for the barcode
 * to have the right printing aspect.
 * @return the barcode <CODE>Image</CODE>
 * @throws BadElementException on error
 */    
public Image getImage() throws BadElementException {
    paintCode();
    byte g4[] = CCITTG4Encoder.compress(outBits, bitColumns, codeRows);
    return Image.getInstance(bitColumns, codeRows, false, Image.CCITTG4, (options & PDF417_INVERT_BITMAP) == 0 ? 0 : Image.CCITT_BLACKIS1, g4, null);
}