use of java.awt.Transparency in project netbeans-rcp-lite by outersky.
the class ImageUtilities method doMergeImages.
private static final ToolTipImage doMergeImages(Image image1, Image image2, int x, int y) {
ensureLoaded(image1);
ensureLoaded(image2);
int w = Math.max(image1.getWidth(null), x + image2.getWidth(null));
int h = Math.max(image1.getHeight(null), y + image2.getHeight(null));
boolean bitmask = (image1 instanceof Transparency) && ((Transparency) image1).getTransparency() != Transparency.TRANSLUCENT && (image2 instanceof Transparency) && ((Transparency) image2).getTransparency() != Transparency.TRANSLUCENT;
StringBuilder str = new StringBuilder(image1 instanceof ToolTipImage ? ((ToolTipImage) image1).toolTipText : "");
if (image2 instanceof ToolTipImage) {
String toolTip = ((ToolTipImage) image2).toolTipText;
if (str.length() > 0 && toolTip.length() > 0) {
str.append(TOOLTIP_SEPAR);
}
str.append(toolTip);
}
Object firstUrl = image1.getProperty("url", null);
ColorModel model = colorModel(bitmask ? Transparency.BITMASK : Transparency.TRANSLUCENT);
// Provide a delegate Icon for scalable rendering.
Icon delegateIcon = new MergedIcon(image2Icon(image1), image2Icon(image2), x, y);
ToolTipImage buffImage = new ToolTipImage(str.toString(), delegateIcon, model, model.createCompatibleWritableRaster(w, h), model.isAlphaPremultiplied(), null, firstUrl instanceof URL ? (URL) firstUrl : null);
// Also provide an Image-based rendering for backwards-compatibility.
java.awt.Graphics g = buffImage.createGraphics();
g.drawImage(image1, 0, 0, null);
g.drawImage(image2, x, y, null);
g.dispose();
return buffImage;
}
Aggregations