Java 类com.lowagie.text.ImgRaw 实例源码

项目:itext2    文件:BmpImage.java   
private Image indexedModel(byte bdata[], int bpc, int paletteEntries) throws BadElementException {
    Image img = new ImgRaw(width, height, 1, bpc, bdata);
    PdfArray colorspace = new PdfArray();
    colorspace.add(PdfName.INDEXED);
    colorspace.add(PdfName.DEVICERGB);
    byte np[] = getPalette(paletteEntries);
    int len = np.length;
    colorspace.add(new PdfNumber(len / 3 - 1));
    colorspace.add(new PdfString(np));
    PdfDictionary ad = new PdfDictionary();
    ad.put(PdfName.COLORSPACE, colorspace);
    img.setAdditional(ad);
    return img;
}
项目:DroidText    文件:BmpImage.java   
private Image indexedModel(byte bdata[], int bpc, int paletteEntries) throws BadElementException {
    Image img = new ImgRaw(width, height, 1, bpc, bdata);
    PdfArray colorspace = new PdfArray();
    colorspace.add(PdfName.INDEXED);
    colorspace.add(PdfName.DEVICERGB);
    byte np[] = getPalette(paletteEntries);
    int len = np.length;
    colorspace.add(new PdfNumber(len / 3 - 1));
    colorspace.add(new PdfString(np));
    PdfDictionary ad = new PdfDictionary();
    ad.put(PdfName.COLORSPACE, colorspace);
    img.setAdditional(ad);
    return img;
}
项目:itext2    文件:BmpImage.java   
private Image read1632Bit(boolean is32) throws IOException, BadElementException {

    int red_mask = findMask(redMask);
    int red_shift = findShift(redMask);
    int red_factor = red_mask + 1;
    int green_mask = findMask(greenMask);
    int green_shift = findShift(greenMask);
    int green_factor = green_mask + 1;
    int blue_mask = findMask(blueMask);
    int blue_shift = findShift(blueMask);
    int blue_factor = blue_mask + 1;
    byte bdata[] = new byte[width * height * 3];
    // Padding bytes at the end of each scanline
    int padding = 0;

    if (!is32) {
    // width * bitsPerPixel should be divisible by 32
        int bitsPerScanline = width * 16;
        if ( bitsPerScanline%32 != 0) {
            padding = (bitsPerScanline/32 + 1)*32 - bitsPerScanline;
            padding = (int)Math.ceil(padding/8.0);
        }
    }

    int imSize = (int)imageSize;
    if (imSize == 0) {
        imSize = (int)(bitmapFileSize - bitmapOffset);
    }

    int l=0;
    int v;
    if (isBottomUp) {
        for (int i=height - 1; i >= 0; --i) {
            l = width * 3 * i;
            for (int j=0; j<width; j++) {
                if (is32)
                    v = (int)readDWord(inputStream);
                else
                    v = readWord(inputStream);
                bdata[l++] = (byte)(((v >>> red_shift) & red_mask) * 256 / red_factor);
                bdata[l++] = (byte)(((v >>> green_shift) & green_mask) * 256 / green_factor);
                bdata[l++] = (byte)(((v >>> blue_shift) & blue_mask) * 256 / blue_factor);
            }
            for (int m=0; m<padding; m++) {
                inputStream.read();
            }
        }
    } else {
        for (int i=0; i<height; i++) {
            for (int j=0; j<width; j++) {
                if (is32)
                    v = (int)readDWord(inputStream);
                else
                    v = readWord(inputStream);
                bdata[l++] = (byte)(((v >>> red_shift) & red_mask) * 256 / red_factor);
                bdata[l++] = (byte)(((v >>> green_shift) & green_mask) * 256 / green_factor);
                bdata[l++] = (byte)(((v >>> blue_shift) & blue_mask) * 256 / blue_factor);
            }
            for (int m=0; m<padding; m++) {
                inputStream.read();
            }
        }
    }
    return new ImgRaw(width, height, 3, 8, bdata);
}
项目:DroidText    文件:BmpImage.java   
private Image read1632Bit(boolean is32) throws IOException, BadElementException {

    int red_mask = findMask(redMask);
    int red_shift = findShift(redMask);
    int red_factor = red_mask + 1;
    int green_mask = findMask(greenMask);
    int green_shift = findShift(greenMask);
    int green_factor = green_mask + 1;
    int blue_mask = findMask(blueMask);
    int blue_shift = findShift(blueMask);
    int blue_factor = blue_mask + 1;
    byte bdata[] = new byte[width * height * 3];
    // Padding bytes at the end of each scanline
    int padding = 0;

    if (!is32) {
    // width * bitsPerPixel should be divisible by 32
        int bitsPerScanline = width * 16;
        if ( bitsPerScanline%32 != 0) {
            padding = (bitsPerScanline/32 + 1)*32 - bitsPerScanline;
            padding = (int)Math.ceil(padding/8.0);
        }
    }

    int imSize = (int)imageSize;
    if (imSize == 0) {
        imSize = (int)(bitmapFileSize - bitmapOffset);
    }

    int l=0;
    int v;
    if (isBottomUp) {
        for (int i=height - 1; i >= 0; --i) {
            l = width * 3 * i;
            for (int j=0; j<width; j++) {
                if (is32)
                    v = (int)readDWord(inputStream);
                else
                    v = readWord(inputStream);
                bdata[l++] = (byte)(((v >>> red_shift) & red_mask) * 256 / red_factor);
                bdata[l++] = (byte)(((v >>> green_shift) & green_mask) * 256 / green_factor);
                bdata[l++] = (byte)(((v >>> blue_shift) & blue_mask) * 256 / blue_factor);
            }
            for (int m=0; m<padding; m++) {
                inputStream.read();
            }
        }
    } else {
        for (int i=0; i<height; i++) {
            for (int j=0; j<width; j++) {
                if (is32)
                    v = (int)readDWord(inputStream);
                else
                    v = readWord(inputStream);
                bdata[l++] = (byte)(((v >>> red_shift) & red_mask) * 256 / red_factor);
                bdata[l++] = (byte)(((v >>> green_shift) & green_mask) * 256 / green_factor);
                bdata[l++] = (byte)(((v >>> blue_shift) & blue_mask) * 256 / blue_factor);
            }
            for (int m=0; m<padding; m++) {
                inputStream.read();
            }
        }
    }
    return new ImgRaw(width, height, 3, 8, bdata);
}