Package org.apache.pdfbox.pdmodel.common

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


     * @return The domain range for this component.
     */
    public PDRange getDomainForInput(int n)
    {
        COSArray domainValues = getDomainValues();
        return new PDRange( domainValues, n );
    }
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 numberOfInputValues = input.length;
        int numberOfOutputValues = getNumberOfOutputParameters();
        int[] intInputValuesPrevious = new int[numberOfInputValues];
        int[] intInputValuesNext = new int[numberOfInputValues];
        for (int i=0; i<numberOfInputValues; i++) {
            PDRange domain = getDomainForInput(i);
            PDRange encode = getEncodeForParameter(i);
            input[i] = clipToRange(input[i], domain.getMin(), domain.getMax());
            input[i] = interpolate(input[i], domain.getMin(), domain.getMax(), encode.getMin(), encode.getMax());
            input[i] = clipToRange(input[i], 0, sizeValues[i]-1);
            intInputValuesPrevious[i] = (int)Math.floor(input[i]);
            intInputValuesNext[i] = (int)Math.ceil(input[i]);
        }
        float[] outputValuesPrevious = null;
        float[] outputValuesNext = null;
        outputValuesPrevious = getSample(intInputValuesPrevious);
        outputValuesNext = getSample(intInputValuesNext);
        float[] outputValues = new float[numberOfOutputValues];
        for (int i=0;i<numberOfOutputValues;i++)
        {
            PDRange range = getRangeForOutput(i);
            PDRange decode = getDecodeForParameter(i);
            // TODO using only a linear interpolation.
            // See "Order" entry in table 3.36 of the PDF reference
            outputValues[i] = (outputValuesPrevious[i] + outputValuesNext[i]) / 2;
            outputValues[i] = interpolate(outputValues[i], 0, (float)Math.pow(2, bitsPerSample), decode.getMin(), decode.getMax());
            outputValues[i] = clipToRange(outputValues[i], range.getMin(), range.getMax());
        }

        return outputValues;
    }
View Full Code Here

        //Setup the input values
        int numberOfInputValues = input.length;
        ExecutionContext context = new ExecutionContext(OPERATORS);
        for (int i = numberOfInputValues - 1; i >= 0; 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

     * @return The range for this component.
     */
    public PDRange getRangeForComponent( int n )
    {
        COSArray rangeArray = getRangeArray( n );
        return new PDRange( rangeArray, n );
    }
View Full Code Here

     * @return The range for this component.
     */
    public PDRange getRangeForOutput(int n)
    {
        COSArray rangeValues = getRangeValues();
        return new PDRange( rangeValues, n );
    }
View Full Code Here

     * @return The domain range for this component.
     */
    public PDRange getDomainForInput(int n)
    {
        COSArray domainValues = getDomainValues();
        return new PDRange( domainValues, n );
    }
View Full Code Here

    // get the patch list which forms the type 7 shading image from data stream
    private ArrayList<Patch> getTensorPatchList(AffineTransform xform, Matrix ctm) throws IOException
    {
        PDShadingType7 tensorShadingType = (PDShadingType7) patchMeshesShadingType;
        COSDictionary cosDictionary = tensorShadingType.getCOSDictionary();
        PDRange rangeX = tensorShadingType.getDecodeForParameter(0);
        PDRange rangeY = tensorShadingType.getDecodeForParameter(1);
        PDRange[] colRange = new PDRange[numberOfColorComponents];
        for (int i = 0; i < numberOfColorComponents; ++i)
        {
            colRange[i] = tensorShadingType.getDecodeForParameter(2 + i);
        }
View Full Code Here

        COSArray rangeArray = (COSArray) dictionary.getDictionaryObject(COSName.RANGE);
        if (rangeArray == null)
        {
            rangeArray = getDefaultRangeArray();
        }
        return new PDRange(rangeArray, 0);
    }
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.