org.jpedal.parser.color.SCN Maven / Gradle / Ivy
/*
* ===========================================
* Java Pdf Extraction Decoding Access Library
* ===========================================
*
* Project Info: http://www.idrsolutions.com
* Help section for developers at http://www.idrsolutions.com/support/
*
* (C) Copyright 1997-2017 IDRsolutions and Contributors.
*
* This file is part of JPedal/JPDF2HTML5
*
@LICENSE@
*
* ---------------
* SCN.java
* ---------------
*/
package org.jpedal.parser.color;
import org.jpedal.color.ColorSpaces;
import org.jpedal.objects.GraphicsState;
import org.jpedal.parser.CommandParser;
import org.jpedal.parser.PdfObjectCache;
/**
*
*/
public class SCN {
public static void execute(final boolean isLowerCase, final GraphicsState gs, final CommandParser parser, final PdfObjectCache cache) {
float[] values;
if (isLowerCase) {
if (gs.nonstrokeColorSpace.getID() == ColorSpaces.Pattern) {
final String[] vals = parser.getValuesAsString();
gs.nonstrokeColorSpace.setColor(vals, vals.length);
} else {
values = parser.getValuesAsFloat();
final int operandCount = values.length;
final float[] tempValues = new float[operandCount];
for (int ii = 0; ii < operandCount; ii++) {
tempValues[operandCount - ii - 1] = values[ii];
}
values = tempValues;
//System.out.println(nonstrokeColorSpace);
gs.nonstrokeColorSpace.setColor(values, operandCount);
}
//track colrspace use
cache.put(PdfObjectCache.ColorspacesUsed, gs.nonstrokeColorSpace.getID(), "x");
} else {
if (gs.strokeColorSpace.getID() == ColorSpaces.Pattern) {
final String[] vals = parser.getValuesAsString();
gs.strokeColorSpace.setColor(vals, vals.length);
} else {
values = parser.getValuesAsFloat();
final int operandCount = values.length;
final float[] tempValues = new float[operandCount];
for (int ii = 0; ii < operandCount; ii++) {
tempValues[operandCount - ii - 1] = values[ii];
}
values = tempValues;
gs.strokeColorSpace.setColor(values, operandCount);
}
//track colrspace use
cache.put(PdfObjectCache.ColorspacesUsed, gs.strokeColorSpace.getID(), "x");
}
}
}