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;
}
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);
}
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;
}
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;
}
Aggregations