public boolean is_INT_PACK(ColorModel cm) { // Check ColorModel is of type DirectColorModel if(!(cm instanceof PackedColorModel)) return false; PackedColorModel pcm = (PackedColorModel)cm; int [] masks = pcm.getMasks(); // Check transfer type if(masks.length != 4) return false; if (masks[0] != 0x00ff0000) return false; if (masks[1] != 0x0000ff00) return false; if (masks[2] != 0x000000ff) return false; if (masks[3] != 0xff000000) return false; return true; }
public Struct info() throws ExpressionException{ if(sctInfo!=null) return sctInfo; Struct sctInfo=new StructImpl(),sct; sctInfo.setEL("height",new Double(getHeight())); sctInfo.setEL("width",new Double(getWidth())); sctInfo.setEL("source",source==null?"":source.getAbsolutePath()); //sct.setEL("mime_type",getMimeType()); ColorModel cm = image().getColorModel(); sct=new StructImpl(); sctInfo.setEL("colormodel",sct); sct.setEL("alpha_channel_support",Caster.toBoolean(cm.hasAlpha())); sct.setEL("alpha_premultiplied",Caster.toBoolean(cm.isAlphaPremultiplied())); sct.setEL("transparency",toStringTransparency(cm.getTransparency())); sct.setEL("pixel_size",Caster.toDouble(cm.getPixelSize())); sct.setEL("num_components",Caster.toDouble(cm.getNumComponents())); sct.setEL("num_color_components",Caster.toDouble(cm.getNumColorComponents())); sct.setEL("colorspace",toStringColorSpace(cm.getColorSpace())); //bits_component int[] bitspercomponent = cm.getComponentSize(); Array arr=new ArrayImpl(); Double value; for (int i = 0; i < bitspercomponent.length; i++) { sct.setEL("bits_component_" + (i + 1),value=new Double(bitspercomponent[i])); arr.appendEL(value); } sct.setEL("bits_component",arr); // colormodel_type if (cm instanceof ComponentColorModel) sct.setEL("colormodel_type", "ComponentColorModel"); else if (cm instanceof IndexColorModel) sct.setEL("colormodel_type", "IndexColorModel"); else if (cm instanceof PackedColorModel) sct.setEL("colormodel_type", "PackedColorModel"); else sct.setEL("colormodel_type", ListUtil.last(cm.getClass().getName(), '.')); getMetaData(sctInfo); ImageMeta.addInfo(format,source,sctInfo); this.sctInfo=sctInfo; return sctInfo; }
public Struct info() throws PageException { if(sctInfo!=null) return sctInfo; Struct sctInfo=new StructImpl(),sct; ImageMetaDrew.addInfo(format,source,sctInfo); sctInfo=ImageGetEXIFMetadata.flatten(sctInfo); sctInfo.setEL(KeyConstants._height,new Double(getHeight())); sctInfo.setEL(KeyConstants._width,new Double(getWidth())); sctInfo.setEL(KeyConstants._source,source==null?"":source.getAbsolutePath()); //sct.setEL("mime_type",getMimeType()); ColorModel cm = image().getColorModel(); sct=new StructImpl(); sctInfo.setEL("colormodel",sct); sct.setEL("alpha_channel_support",Caster.toBoolean(cm.hasAlpha())); sct.setEL("alpha_premultiplied",Caster.toBoolean(cm.isAlphaPremultiplied())); sct.setEL("transparency",toStringTransparency(cm.getTransparency())); sct.setEL("pixel_size",Caster.toDouble(cm.getPixelSize())); sct.setEL("num_components",Caster.toDouble(cm.getNumComponents())); sct.setEL("num_color_components",Caster.toDouble(cm.getNumColorComponents())); sct.setEL("colorspace",toStringColorSpace(cm.getColorSpace())); //bits_component int[] bitspercomponent = cm.getComponentSize(); Array arr=new ArrayImpl(); Double value; for (int i = 0; i < bitspercomponent.length; i++) { sct.setEL("bits_component_" + (i + 1),value=new Double(bitspercomponent[i])); arr.appendEL(value); } sct.setEL("bits_component",arr); // colormodel_type if (cm instanceof ComponentColorModel) sct.setEL("colormodel_type", "ComponentColorModel"); else if (cm instanceof IndexColorModel) sct.setEL("colormodel_type", "IndexColorModel"); else if (cm instanceof PackedColorModel) sct.setEL("colormodel_type", "PackedColorModel"); else sct.setEL("colormodel_type", ListUtil.last(cm.getClass().getName(), '.')); getMetaData(sctInfo); //Metadata.addInfo(format,source,sctInfo); Metadata.addExifInfo(format,source,sctInfo); this.sctInfo=sctInfo; return sctInfo; }
/** * Constructs a <code>PixelAccessor</code> given a valid * <code>SampleModel</code> and a (possibly <code>null</code>) * <code>ColorModel</code>. * * @param sm The <code>SampleModel</code> for the image to be accessed. * Must be valid. * @param cm The <code>ColorModel</code> for the image to be accessed. * May be null. * @throws IllegalArgumentException If <code>sm</code> is <code>null</code>. */ public PixelAccessor(SampleModel sm, ColorModel cm) { if ( sm == null ) { throw new IllegalArgumentException(JaiI18N.getString("Generic0")); } sampleModel = sm; colorModel = cm; // Information from the SampleModel. isComponentSM = sampleModel instanceof ComponentSampleModel; isMultiPixelPackedSM = sampleModel instanceof MultiPixelPackedSampleModel; isSinglePixelPackedSM = sampleModel instanceof SinglePixelPackedSampleModel; bufferType = sampleModel.getDataType(); transferType = sampleModel.getTransferType(); numBands = sampleModel.getNumBands(); sampleSize = sampleModel.getSampleSize(); sampleType = isComponentSM ? bufferType : getType(sampleSize); // Indicates whether the pixel data may be stored in packed format. isPacked = sampleType == TYPE_BIT && numBands == 1; // Information from the ColorModel. hasCompatibleCM = colorModel != null && JDKWorkarounds.areCompatibleDataModels(sampleModel, colorModel); if (hasCompatibleCM) { isComponentCM = colorModel instanceof ComponentColorModel; isIndexCM = colorModel instanceof IndexColorModel; isPackedCM = colorModel instanceof PackedColorModel; numComponents = colorModel.getNumComponents(); componentSize = colorModel.getComponentSize(); int tempType = getType(componentSize); componentType = (tempType == TYPE_BIT) ? DataBuffer.TYPE_BYTE : tempType; } else { isComponentCM = false; isIndexCM = false; isPackedCM = false; numComponents = numBands; componentSize = sampleSize; componentType = sampleType; } }