Search in sources :

Example 71 with IndexColorModel

use of java.awt.image.IndexColorModel in project vcell by virtualcell.

the class OverlayEditorPanelJAI method getHiliteColorModel.

private IndexColorModel getHiliteColorModel() {
    if (hiLiteColorModel == null) {
        int[] cmap = new int[256];
        for (int i = 0; i < 256; i += 1) {
            if (i != 0) {
                cmap[i] = 0xFF000000 | highlightColor.getRGB();
            } else {
                cmap[1] = 0xFF000000;
            }
        }
        hiLiteColorModel = new java.awt.image.IndexColorModel(8, cmap.length, cmap, 0, false, /*false means NOT USE alpha*/
        -1, /*NO transparent single pixel*/
        java.awt.image.DataBuffer.TYPE_BYTE);
    }
    return hiLiteColorModel;
}
Also used : IndexColorModel(java.awt.image.IndexColorModel) Point(java.awt.Point)

Example 72 with IndexColorModel

use of java.awt.image.IndexColorModel in project vcell by virtualcell.

the class VFrapXmlHelper method LoadVFrapDisplayRoi.

// load ROI images
public static void LoadVFrapDisplayRoi(Hashtable<String, Object> hashTable, AnnotatedImageDataset annotatedImages, ROI[] rois) {
    // was roiComposite
    BufferedImage[] displayROI = null;
    // make roi composite
    int[] cmap = new int[256];
    for (int i = 0; i < 256; i += 1) {
        cmap[i] = OverlayEditorPanelJAI.CONTRAST_COLORS[i].getRGB();
        if (i == 0) {
            cmap[i] = new Color(0, 0, 0, 0).getRGB();
        }
    }
    IndexColorModel indexColorModel = new java.awt.image.IndexColorModel(8, cmap.length, cmap, 0, // false means NOT USE alpha
    false, // NO transparent single pixel
    -1, java.awt.image.DataBuffer.TYPE_BYTE);
    displayROI = new BufferedImage[annotatedImages.getImageDataset().getSizeZ()];
    for (int i = 0; i < displayROI.length; i++) {
        displayROI[i] = new BufferedImage(annotatedImages.getImageDataset().getISize().getX(), annotatedImages.getImageDataset().getISize().getY(), BufferedImage.TYPE_BYTE_INDEXED, indexColorModel);
    }
    int xysize = annotatedImages.getImageDataset().getISize().getX() * annotatedImages.getImageDataset().getISize().getY();
    for (int i = 0; i < rois.length; i++) {
        short[] roiBits = rois[i].getBinaryPixelsXYZ(1);
        for (int j = 0; j < roiBits.length; j++) {
            int roiZindex = j / (xysize);
            byte[] roiData = ((DataBufferByte) displayROI[roiZindex].getRaster().getDataBuffer()).getData();
            if (roiBits[j] != 0 && (rois[i].getROIName().equals(AnnotatedImageDataset.VFRAP_ROI_ENUM.ROI_BLEACHED) || roiData[j % xysize] == 0)) {
                roiData[j % xysize] = (byte) (i + 1);
            // if(i!= 0){
            // System.out.println("roi="+i+" j="+j+" j%="+(j%xysize)+" z="+roiZindex+" roidata="+roiData[j%xysize]);
            // }
            }
        }
    }
    hashTable.put("displayROI", displayROI);
}
Also used : Color(java.awt.Color) DataBufferByte(java.awt.image.DataBufferByte) BufferedImage(java.awt.image.BufferedImage) IndexColorModel(java.awt.image.IndexColorModel)

Example 73 with IndexColorModel

use of java.awt.image.IndexColorModel in project Lucee by lucee.

the class Image method info.

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;
}
Also used : Array(lucee.runtime.type.Array) PackedColorModel(java.awt.image.PackedColorModel) StructImpl(lucee.runtime.type.StructImpl) IndexColorModel(java.awt.image.IndexColorModel) DirectColorModel(java.awt.image.DirectColorModel) ComponentColorModel(java.awt.image.ComponentColorModel) PackedColorModel(java.awt.image.PackedColorModel) ColorModel(java.awt.image.ColorModel) ComponentColorModel(java.awt.image.ComponentColorModel) ArrayImpl(lucee.runtime.type.ArrayImpl) Point(java.awt.Point) Struct(lucee.runtime.type.Struct) IndexColorModel(java.awt.image.IndexColorModel)

Example 74 with IndexColorModel

use of java.awt.image.IndexColorModel in project Lucee by lucee.

the class ImageUtil method createBufferedImage.

public static BufferedImage createBufferedImage(BufferedImage image, int columns, int rows) {
    ColorModel colormodel = image.getColorModel();
    BufferedImage newImage;
    if (colormodel instanceof IndexColorModel) {
        if (colormodel.getTransparency() != 1)
            newImage = new BufferedImage(columns, rows, 2);
        else
            newImage = new BufferedImage(columns, rows, 1);
    } else {
        newImage = new BufferedImage(colormodel, image.getRaster().createCompatibleWritableRaster(columns, rows), colormodel.isAlphaPremultiplied(), null);
    }
    return newImage;
}
Also used : ColorModel(java.awt.image.ColorModel) IndexColorModel(java.awt.image.IndexColorModel) BufferedImage(java.awt.image.BufferedImage) IndexColorModel(java.awt.image.IndexColorModel)

Aggregations

IndexColorModel (java.awt.image.IndexColorModel)74 ColorModel (java.awt.image.ColorModel)30 BufferedImage (java.awt.image.BufferedImage)29 DirectColorModel (java.awt.image.DirectColorModel)17 Point (java.awt.Point)14 WritableRaster (java.awt.image.WritableRaster)12 SampleModel (java.awt.image.SampleModel)10 ComponentColorModel (java.awt.image.ComponentColorModel)8 Rectangle (java.awt.Rectangle)7 DataBufferByte (java.awt.image.DataBufferByte)7 MultiPixelPackedSampleModel (java.awt.image.MultiPixelPackedSampleModel)7 Raster (java.awt.image.Raster)7 ComponentSampleModel (java.awt.image.ComponentSampleModel)6 Graphics2D (java.awt.Graphics2D)5 ColorSpace (java.awt.color.ColorSpace)5 Color (java.awt.Color)4 Graphics (java.awt.Graphics)4 ICC_ColorSpace (java.awt.color.ICC_ColorSpace)4 SinglePixelPackedSampleModel (java.awt.image.SinglePixelPackedSampleModel)4 IOException (java.io.IOException)4