Examples of PDColorSpace


Examples of org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

    protected void checkColorSpace(PreflightContext context, PDPage page, PDShading shadingRes)
            throws ValidationException
            {
        try
        {
            PDColorSpace pColorSpace = shadingRes.getColorSpace();
            PreflightConfiguration config = context.getConfig();
            ColorSpaceHelperFactory csFact = config.getColorSpaceHelperFact();
            ColorSpaceHelper csh = csFact.getColorSpaceHelper(context, pColorSpace, ColorSpaceRestriction.NO_PATTERN);
            csh.validate();
        }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

            ColorSpaceHelperFactory colorSpaceFactory = config.getColorSpaceHelperFact();
            for (COSName name : resources.getColorSpaceNames())
            {
                try
                {
                    PDColorSpace pdCS = resources.getColorSpace(name);
                    ColorSpaceHelper csHelper = colorSpaceFactory.getColorSpaceHelper(context, pdCS,
                            ColorSpaceRestriction.NO_RESTRICTION);
                    csHelper.validate();
                }
                catch (IOException e)
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

            {
                context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_ICCBASED,
                        "Unable to read ICCBase color space "));
                return;
            }
            PDColorSpace altpdcs = iccBased.getAlternateColorSpace();
            if (altpdcs != null)
            {
                ColorSpaces altCsId = ColorSpaces.valueOf(altpdcs.getName());
                if (altCsId == ColorSpaces.Pattern)
                {
                    context.addValidationError(new ValidationError(
                            ERROR_GRAPHIC_INVALID_PATTERN_COLOR_SPACE_FORBIDDEN,
                            "Pattern is forbidden as AlternateColorSpace of a ICCBased"));
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

                        "DestOutputProfile is missing"));
                return;
            }

            COSBase cosAlt = ((COSArray)pdcs.getCOSObject()).getObject(2);
            PDColorSpace altColor = PDColorSpace.create(cosAlt);
            if (altColor != null)
            {
                processAllColorSpace(altColor);
            }
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

     *            the color space object to check.
     */
    protected void processIndexedColorSpace(PDColorSpace pdcs)
    {
        PDIndexed indexed = (PDIndexed) pdcs;
        PDColorSpace based = indexed.getBaseColorSpace();
        ColorSpaces cs = ColorSpaces.valueOf(based.getName());
        if (cs == ColorSpaces.Indexed || cs == ColorSpaces.Indexed_SHORT)
        {
            context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_INDEXED,
                    "Indexed color space can't be used as Base color space"));
            return;
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

    protected void processSeparationColorSpace(PDColorSpace pdcs)
    {
        try
        {
            COSBase cosAlt = ((COSArray)pdcs.getCOSObject()).getObject(2);
            PDColorSpace altCol = PDColorSpace.create(cosAlt);
            if (altCol != null)
            {
                ColorSpaces acs = ColorSpaces.valueOf(altCol.getName());
                switch (acs)
                {
                case Separation:
                case DeviceN:
                case Pattern:
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

        // get default color space
        PreflightPath vPath = context.getValidationPath();
        PDResources resources = vPath.getClosestPathElement(PDResources.class);
        if (resources != null)
        {
            PDColorSpace defaultCS = null;

            try
            {
                if (pdcs.getName().equals(ColorSpaces.DeviceCMYK.getLabel()) &&
                    resources.hasColorSpace(COSName.DEFAULT_CMYK))
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

     * false.
     */
    protected void processIndexedColorSpace(PDColorSpace pdcs)
    {
        PDIndexed indexed = (PDIndexed) pdcs;
        PDColorSpace based = indexed.getBaseColorSpace();
        ColorSpaces colorSpace = ColorSpaces.valueOf(based.getName());
        switch (colorSpace)
        {
        case Indexed:
        case Indexed_SHORT:
        case Pattern:
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

        {
            throw new IOException("Image stream is empty");
        }

        // get parameters, they must be valid or have been repaired
        final PDColorSpace colorSpace = pdImage.getColorSpace();
        final int numComponents = colorSpace.getNumberOfComponents();
        final int width = pdImage.getWidth();
        final int height = pdImage.getHeight();
        final int bitsPerComponent = pdImage.getBitsPerComponent();
        final float[] decode = getDecodeArray(pdImage);
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

    }
   
    private static BufferedImage from1Bit(PDImage pdImage, WritableRaster raster)
            throws IOException
    {
        final PDColorSpace colorSpace = pdImage.getColorSpace();
        final int width = pdImage.getWidth();
        final int height = pdImage.getHeight();
        final float[] decode = getDecodeArray(pdImage);
        byte[] output = ((DataBufferByte) raster.getDataBuffer()).getData();

        // read bit stream
        InputStream iis = null;
        try
        {
            // create stream
            iis = pdImage.getStream().createInputStream();
            final boolean isIndexed = colorSpace instanceof PDIndexed;

            int rowLen = width / 8;
            if (width % 8 > 0)
            {
                rowLen++;
            }

            // read stream
            byte value0;
            byte value1;
            if (isIndexed || decode[0] < decode[1])
            {
                value0 = 0;
                value1 = (byte) 255;
            }
            else
            {
                value0 = (byte) 255;
                value1 = 0;
            }
            byte[] buff = new byte[rowLen];
            int idx = 0;
            for (int y = 0; y < height; y++)
            {
                int x = 0;
                iis.read(buff);
                for (int r = 0; r < rowLen; r++)
                {
                    int value = buff[r];
                    int mask = 128;
                    for (int i = 0; i < 8; i++)
                    {
                        int bit = value & mask;
                        mask >>= 1;
                        output[idx++] = bit == 0 ? value0 : value1;
                        x++;
                        if (x == width)
                        {
                            break;
                        }
                    }
                }
            }

            // use the color space to convert the image to RGB
            BufferedImage rgbImage = colorSpace.toRGBImage(raster);

            return rgbImage;
        }
        finally
        {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.