Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2019-04-03 16:11:34 -0400
committerXi Yan2019-04-03 16:42:49 -0400
commit2dfa77fb07779dbb9c647dc96a4c6628321df4a3 (patch)
treef512bf865aff0c1055218a783790b4e2971e4e8d
parent46bc7dbe16e739168bd3c11a87e9eb5281f9f2ab (diff)
downloadeclipse.platform.swt-2dfa77fb07779dbb9c647dc96a4c6628321df4a3.tar.gz
eclipse.platform.swt-2dfa77fb07779dbb9c647dc96a4c6628321df4a3.tar.xz
eclipse.platform.swt-2dfa77fb07779dbb9c647dc96a4c6628321df4a3.zip
Bug 546096 - [GTK3] TextEditor toolbar icon wrong transparency
Add additional means of getting transparencyMask from alphaData. We should not get mask from transparentPixel if we already have alphaData. Change-Id: I546a4a120babbfe28e7e7d9dfee2c2b75569d3dc Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
index a6781948de..d13ecb1105 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
@@ -1073,13 +1073,31 @@ public RGB[] getRGBs() {
* @return the transparency mask
*/
public ImageData getTransparencyMask() {
- if (getTransparencyType() == SWT.TRANSPARENCY_MASK) {
- return new ImageData(width, height, 1, bwPalette(), maskPad, maskData);
- } else {
- return colorMaskImage(transparentPixel);
+ int transparencyType = getTransparencyType();
+ switch (transparencyType) {
+ case SWT.TRANSPARENCY_ALPHA: return getTransparencyMaskFromAlphaData();
+ case SWT.TRANSPARENCY_MASK: return new ImageData(width, height, 1, bwPalette(), maskPad, maskData);
+ case SWT.TRANSPARENCY_PIXEL: return colorMaskImage(transparentPixel);
+ default: return colorMaskImage(transparentPixel);
}
}
+ImageData getTransparencyMaskFromAlphaData() {
+ ImageData mask = new ImageData(width, height, 1, bwPalette(), 2, null, 0, null, null, -1, -1, SWT.IMAGE_UNDEFINED, 0, 0, 0, 0);
+ int offset = 0;
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ byte a = alphaData[offset++];
+ if (a == 0) {
+ mask.setPixel(x, y, 0);
+ } else {
+ mask.setPixel(x, y, 1);
+ }
+ }
+ }
+ return mask;
+}
+
/**
* Returns the image transparency type, which will be one of
* <code>SWT.TRANSPARENCY_NONE</code>, <code>SWT.TRANSPARENCY_MASK</code>,

Back to the top