public XObjImageValidator(PreflightContext context, PDImageXObject xobj) { super(context, xobj.getCOSObject()); this.xImage = xobj; }
/** * Sets the metadata associated with this XObject, or null if there is none. * @param meta the metadata associated with this object */ public void setMetadata(PDMetadata meta) { getCOSObject().setItem(COSName.METADATA, meta); }
/** * Sets the key of this XObject in the structural parent tree. * @param key the new key for this XObject */ public void setStructParent(int key) { getCOSObject().setInt(COSName.STRUCT_PARENT, key); }
@Override public COSArray getDecode() { COSBase decode = getCOSObject().getDictionaryObject(COSName.DECODE); if (decode instanceof COSArray) { return (COSArray) decode; } return null; }
@Override public int getWidth() { return getCOSObject().getInt(COSName.WIDTH); }
@Override public void setWidth(int w) { getCOSObject().setInt(COSName.WIDTH, w); }
@Override public boolean isStencil() { return getCOSObject().getBoolean(COSName.IMAGE_MASK, false); }
@Override public void setStencil(boolean isStencil) { getCOSObject().setBoolean(COSName.IMAGE_MASK, isStencil); }
/** * Returns the key of this XObject in the structural parent tree. * * @return this object's key the structural parent tree or -1 if there isn't any. */ public int getStructParent() { return getCOSObject().getInt(COSName.STRUCT_PARENT); }
@Override public void setBitsPerComponent(int bpc) { getCOSObject().setInt(COSName.BITS_PER_COMPONENT, bpc); }
@Override public int getHeight() { return getCOSObject().getInt(COSName.HEIGHT); }
@Override public void setHeight(int h) { getCOSObject().setInt(COSName.HEIGHT, h); }
@Override public boolean getInterpolate() { return getCOSObject().getBoolean(COSName.INTERPOLATE, false); }
@Override public void setInterpolate(boolean value) { getCOSObject().setBoolean(COSName.INTERPOLATE, value); }
@Override public void setDecode(COSArray decode) { getCOSObject().setItem(COSName.DECODE, decode); }
/** * Returns the color key mask array associated with this image, or null if there is none. * @return Mask Image XObject */ public COSArray getColorKeyMask() { COSBase mask = getCOSObject().getDictionaryObject(COSName.MASK); if (mask instanceof COSArray) { return (COSArray)mask; } return null; }
@Override public int getBitsPerComponent() { if (isStencil()) { return 1; } else { return getCOSObject().getInt(COSName.BITS_PER_COMPONENT, COSName.BPC); } }
@Override public void setColorSpace(PDColorSpace cs) { getCOSObject().setItem(COSName.COLORSPACE, cs != null ? cs.getCOSObject() : null); }
/** * Returns the metadata associated with this XObject, or null if there is none. * @return the metadata associated with this object. */ public PDMetadata getMetadata() { COSStream cosStream = (COSStream) getCOSObject().getDictionaryObject(COSName.METADATA); if (cosStream != null) { return new PDMetadata(cosStream); } return null; }
private float[] extractMatte(PDImageXObject softMask) throws IOException { COSBase base = softMask.getCOSObject().getItem(COSName.MATTE); float[] matte = null; if (base instanceof COSArray) { // PDFBOX-4267: process /Matte // see PDF specification 1.7, 11.6.5.3 Soft-Mask Images matte = ((COSArray) base).toFloatArray(); // convert to RGB matte = getColorSpace().toRGB(matte); } return matte; }