aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWojciech Sudol2013-09-26 08:37:32 (EDT)
committerGerrit Code Review @ Eclipse.org2013-10-04 10:27:33 (EDT)
commite361bf50db2afd28daa2f3a5e13042ba1cc2eb53 (patch)
treec2d1129bab90145a78c19f42eda544fa55ca841e
parent02bb7ab7f9178a670d9cc09c49a100650e20c8cb (diff)
downloadeclipse.platform.ui-e361bf50db2afd28daa2f3a5e13042ba1cc2eb53.zip
eclipse.platform.ui-e361bf50db2afd28daa2f3a5e13042ba1cc2eb53.tar.gz
eclipse.platform.ui-e361bf50db2afd28daa2f3a5e13042ba1cc2eb53.tar.bz2
Bug 372956 - [Decorators] [JFace] CompositeImageDescriptor throws NPErefs/changes/95/16795/2
during Decoration Change-Id: I26b098bd5b53200cc6c2c12da8de402458969e72 Signed-off-by: Wojciech Sudol <wojciech.sudol@pl.ibm.com>
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/resource/CompositeImageDescriptor.java25
1 files changed, 14 insertions, 11 deletions
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/CompositeImageDescriptor.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/CompositeImageDescriptor.java
index 9f2ec2b..4355753 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/CompositeImageDescriptor.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/CompositeImageDescriptor.java
@@ -48,7 +48,7 @@ public abstract class CompositeImageDescriptor extends ImageDescriptor {
* the given bounds using one or more calls to the <code>drawImage</code>
* framework method.
* </p>
- *
+ *
* @param width
* the width
* @param height
@@ -63,7 +63,7 @@ public abstract class CompositeImageDescriptor extends ImageDescriptor {
* Call this internal framework method to superimpose another image atop
* this composite image.
* </p>
- *
+ *
* @param src
* the source image data
* @param ox
@@ -72,6 +72,9 @@ public abstract class CompositeImageDescriptor extends ImageDescriptor {
* the y position
*/
final protected void drawImage(ImageData src, int ox, int oy) {
+ if (src == null) {
+ return;
+ }
ImageData dst = imageData;
PaletteData srcPalette = src.palette;
ImageData srcMask = null;
@@ -136,12 +139,12 @@ public abstract class CompositeImageDescriptor extends ImageDescriptor {
dstGreen += (srcGreen - dstGreen) * srcAlpha / 255;
dstBlue += (srcBlue - dstBlue) * srcAlpha / 255;
} else {
- // See Porter T., Duff T. 1984. "Compositing Digital Images".
+ // See Porter T., Duff T. 1984. "Compositing Digital Images".
// Computer Graphics 18 (3): 253259.
dstRed = srcRed * srcAlpha * 255 + dstRed * dstAlpha * (255 - srcAlpha);
dstGreen = srcGreen * srcAlpha * 255 + dstGreen * dstAlpha * (255 - srcAlpha);
dstBlue = srcBlue * srcAlpha * 255 + dstBlue * dstAlpha * (255 - srcAlpha);
- dstAlpha = srcAlpha * 255 + dstAlpha * (255 - srcAlpha);
+ dstAlpha = srcAlpha * 255 + dstAlpha * (255 - srcAlpha);
if (dstAlpha != 0) { // if both original alphas == 0, then all colors are 0
dstRed /= dstAlpha;
dstGreen /= dstAlpha;
@@ -161,14 +164,14 @@ public abstract class CompositeImageDescriptor extends ImageDescriptor {
*/
@Override
public ImageData getImageData() {
- Point size = getSize();
-
+ Point size = getSize();
+
/* Create a 24 bit image data with alpha channel */
imageData = new ImageData(size.x, size.y, 24, new PaletteData(0xFF, 0xFF00, 0xFF0000));
imageData.alphaData = new byte[imageData.width * imageData.height];
-
+
drawCompositeImage(size.x, size.y);
-
+
/* Detect minimum transparency */
boolean transparency = false;
byte[] alphaData = imageData.alphaData;
@@ -195,11 +198,11 @@ public abstract class CompositeImageDescriptor extends ImageDescriptor {
}
return imageData;
}
-
+
/**
* Return the transparent pixel for the receiver.
- * <strong>NOTE</strong> This value is not currently in use in the
+ * <strong>NOTE</strong> This value is not currently in use in the
* default implementation.
* @return int
* @since 3.3
@@ -213,7 +216,7 @@ public abstract class CompositeImageDescriptor extends ImageDescriptor {
* <p>
* Subclasses must implement this framework method.
* </p>
- *
+ *
* @return the x and y size of the image expressed as a point object
*/
protected abstract Point getSize();