Package org.apache.pdfbox.pdmodel.common

Examples of org.apache.pdfbox.pdmodel.common.PDRange


    private ArrayList<ShadedTriangle> getTriangleList(AffineTransform xform, Matrix ctm) throws IOException
    {
        PDShadingType4 freeTriangleShadingType = (PDShadingType4) shading;
        COSDictionary cosDictionary = freeTriangleShadingType.getCOSDictionary();
        PDRange rangeX = freeTriangleShadingType.getDecodeForParameter(0);
        PDRange rangeY = freeTriangleShadingType.getDecodeForParameter(1);
        PDRange[] colRange = new PDRange[numberOfColorComponents];
        for (int i = 0; i < numberOfColorComponents; ++i)
        {
            colRange[i] = freeTriangleShadingType.getDecodeForParameter(2 + i);
        }
View Full Code Here


        COSArray rangeArray = (COSArray) dictionary.getDictionaryObject(COSName.RANGE);
        if (rangeArray == null)
        {
            rangeArray = getDefaultRangeArray();
        }
        return new PDRange(rangeArray, 1);
    }
View Full Code Here

     * @param paramNum the function parameter number
     * @return the decode parameter range or null if none is set
     */
    public PDRange getDecodeForParameter(int paramNum)
    {
        PDRange retval = null;
        COSArray decodeValues = getDecodeValues();
        if (decodeValues != null && decodeValues.size() >= paramNum * 2 + 1)
        {
            retval = new PDRange(decodeValues, paramNum);
        }
        return retval;
    }
View Full Code Here

    // get the patch list which forms the type 6 shading image from data stream
    private ArrayList<Patch> getCoonsPatchList(AffineTransform xform, Matrix ctm) throws IOException
    {
        PDShadingType6 coonsShadingType = (PDShadingType6) patchMeshesShadingType;
        COSDictionary cosDictionary = coonsShadingType.getCOSDictionary();
        PDRange rangeX = coonsShadingType.getDecodeForParameter(0);
        PDRange rangeY = coonsShadingType.getDecodeForParameter(1);

        PDRange[] colRange = new PDRange[numberOfColorComponents];
        for (int i = 0; i < numberOfColorComponents; ++i)
        {
            colRange[i] = coonsShadingType.getDecodeForParameter(2 + i);
View Full Code Here

     *
     * @return The encode parameter range or null if none is set.
     */
    public PDRange getEncodeForParameter(int paramNum)
    {
        PDRange retval = null;
        COSArray encodeValues = getEncodeValues();
        if (encodeValues != null && encodeValues.size() >= paramNum * 2 + 1)
        {
            retval = new PDRange(encodeValues, paramNum);
        }
        return retval;
    }
View Full Code Here

     *
     * @return The decode parameter range or null if none is set.
     */
    public PDRange getDecodeForParameter(int paramNum)
    {
        PDRange retval = null;
        COSArray decodeValues = getDecodeValues();
        if (decodeValues != null && decodeValues.size() >= paramNum * 2 + 1)
        {
            retval = new PDRange(decodeValues, paramNum);
        }
        return retval;
    }
View Full Code Here

        int[] inputPrev = new int[numberOfInputValues];
        int[] inputNext = new int[numberOfInputValues];

        for (int i = 0; i < numberOfInputValues; i++)
        {
            PDRange domain = getDomainForInput(i);
            PDRange encodeValues = getEncodeForParameter(i);
            input[i] = clipToRange(input[i], domain.getMin(), domain.getMax());
            input[i] = interpolate(input[i], domain.getMin(), domain.getMax(),
                    encodeValues.getMin(), encodeValues.getMax());
            input[i] = clipToRange(input[i], 0, sizeValues[i] - 1);
            inputPrev[i] = (int) Math.floor(input[i]);
            inputNext[i] = (int) Math.ceil(input[i]);
        }

        // old code for N=1 and N=2, don't delete in case one uses this for optimization
//
//        if (numberOfInputValues == 1)
//        {
//            int[] sample1 = getSamples()[calcSampleIndex(new int[]
//            {
//                inputPrev[0]
//            })];
//            int[] sample2 = getSamples()[calcSampleIndex(new int[]
//            {
//                inputNext[0]
//            })];
//            for (int i = 0; i < numberOfOutputValues; ++i)
//            {
//                outputValues[i] = inputPrev[0] == inputNext[0] ? sample1[i] : interpolate(input[0], inputPrev[0], inputNext[0], sample1[i], sample2[i]);
//            }
//            //TODO optimize so that sample is collected only when needed
//        }
//        if (numberOfInputValues == 2)
//        {
//            int[] sample1 = getSamples()[calcSampleIndex(new int[]
//            {
//                inputPrev[0], inputPrev[1]
//            })];
//            int[] sample2 = getSamples()[calcSampleIndex(new int[]
//            {
//                inputPrev[0], inputNext[1]
//            })];
//            int[] sample3 = getSamples()[calcSampleIndex(new int[]
//            {
//                inputNext[0], inputPrev[1]
//            })];
//            int[] sample4 = getSamples()[calcSampleIndex(new int[]
//            {
//                inputNext[0], inputNext[1]
//            })];
//
//            for (int i = 0; i < numberOfOutputValues; ++i)
//            {
//                // bilinear color interpolation, see e.g.
//                // http://harmoniccode.blogspot.de/2011/04/bilinear-color-interpolation.html
//                // interpolate the color at top and bottom edges (x-axis)
//                // then interpolate the color between these two results (y-axis)
//                double lowerVal = inputPrev[0] == inputNext[0] ? sample1[i] : interpolate(input[0], inputPrev[0], inputNext[0], sample1[i], sample3[i]);
//                double upperVal = inputPrev[0] == inputNext[0] ? sample2[i] : interpolate(input[0], inputPrev[0], inputNext[0], sample2[i], sample4[i]);
//                outputValues[i] = (float) (inputPrev[1] == inputNext[1] ? lowerVal : interpolate(input[1], inputPrev[1], inputNext[1], (float) lowerVal, (float) upperVal));
//                //TODO optimize so that sample is collected only when needed
//            }
//        }
//       
        float[] outputValues = new Rinterpol(input, inputPrev, inputNext).rinterpolate();

        for (int i = 0; i < numberOfOutputValues; i++)
        {
            PDRange range = getRangeForOutput(i);
            PDRange decodeValues = getDecodeForParameter(i);
            outputValues[i] = interpolate(outputValues[i], 0, maxSample, decodeValues.getMin(), decodeValues.getMax());
            outputValues[i] = clipToRange(outputValues[i], range.getMin(), range.getMax());
        }

        return outputValues;
    }
View Full Code Here

    {
        //Setup the input values
        ExecutionContext context = new ExecutionContext(OPERATORS);
        for (int i = 0; i < input.length; i++)
        {
            PDRange domain = getDomainForInput(i);
            float value = clipToRange(input[i], domain.getMin(), domain.getMax());
            context.getStack().push(value);
        }

        //Execute the type 4 function.
        instructions.execute(context);

        //Extract the output values
        int numberOfOutputValues = getNumberOfOutputParameters();
        int numberOfActualOutputValues = context.getStack().size();
        if (numberOfActualOutputValues < numberOfOutputValues)
        {
            throw new IllegalStateException("The type 4 function returned "
                    + numberOfActualOutputValues
                    + " values but the Range entry indicates that "
                    + numberOfOutputValues + " values be returned.");
        }
        float[] outputValues = new float[numberOfOutputValues];
        for (int i = numberOfOutputValues - 1; i >= 0; i--)
        {
            PDRange range = getRangeForOutput(i);
            outputValues[i] = context.popReal();
            outputValues[i] = clipToRange(outputValues[i], range.getMin(), range.getMax());
        }

        //Return the resulting array
        return outputValues;
    }
View Full Code Here

        //c1,max,..., cn, min, cn,max].
        //
        // see p344
        COSArray decode = (COSArray) cosDictionary.getDictionaryObject(COSName.DECODE);
        LOG.debug("decode: " + decode);
        PDRange rangeX = shadingType5.getDecodeForParameter(0);
        PDRange rangeY = shadingType5.getDecodeForParameter(1);
        LOG.debug("rangeX: " + rangeX.getMin() + ", " + rangeX.getMax());
        LOG.debug("rangeY: " + rangeY.getMin() + ", " + rangeY.getMax());

        PDRange[] colRangeTab = new PDRange[numberOfColorComponents];
        for (int i = 0; i < numberOfColorComponents; ++i)
        {
            colRangeTab[i] = shadingType5.getDecodeForParameter(2 + i);
View Full Code Here

        //c1,max,..., cn, min, cn,max].
        //
        // see p344
        COSArray decode = (COSArray) cosDictionary.getDictionaryObject(COSName.DECODE);
        LOG.debug("decode: " + decode);
        PDRange rangeX = shadingType4.getDecodeForParameter(0);
        PDRange rangeY = shadingType4.getDecodeForParameter(1);
        LOG.debug("rangeX: " + rangeX.getMin() + ", " + rangeX.getMax());
        LOG.debug("rangeY: " + rangeY.getMin() + ", " + rangeY.getMax());

        PDRange[] colRangeTab = new PDRange[numberOfColorComponents];
        for (int i = 0; i < numberOfColorComponents; ++i)
        {
            colRangeTab[i] = shadingType4.getDecodeForParameter(2 + i);
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.pdmodel.common.PDRange

Copyright © 2018 www.massapicom. 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.