X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=inline;f=bundles%2Forg.simantics.utils.ui%2Fsrc%2Forg%2Fsimantics%2Futils%2Fui%2Fgfx%2FAlphaAdjustmentImageDescriptor.java;h=80b39a73bfe6e5abc855b87b8265e4c9157aec16;hb=0d0f89ee7fdf9fa2315ba4d797de202992ae7158;hp=104dd88c7c8db4023d51ed30cce98418c23939d8;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/AlphaAdjustmentImageDescriptor.java b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/AlphaAdjustmentImageDescriptor.java index 104dd88c7..80b39a73b 100644 --- a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/AlphaAdjustmentImageDescriptor.java +++ b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/AlphaAdjustmentImageDescriptor.java @@ -1,102 +1,102 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -/* - * 22.12.2006 - */ -package org.simantics.utils.ui.gfx; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.ImageData; - -/** - * AlphaAdjustmentImageDescriptor multiplies alpha by (adjustment value/256) - *
- * Usage:
- * ImageDescriptor icon;
- * icon = AlphaAdjustmentImageDescriptor.adjustAlpha(icon, 128);
- *
- * @author Toni Kalajainen
- */
-public class AlphaAdjustmentImageDescriptor extends ImageDescriptor {
-
- public static ImageDescriptor adjustAlpha(ImageDescriptor desc, int alphaAdjustment)
- {
- if (alphaAdjustment==256) return desc;
- return new AlphaAdjustmentImageDescriptor(desc, alphaAdjustment);
- }
-
- int alphaAdjustment;
- ImageDescriptor desc;
-
- /**
- *
- * @param original
- * @param alphaAdjustment 0..256
- */
- public AlphaAdjustmentImageDescriptor(ImageDescriptor original, int alphaAdjustment)
- {
- assert(alphaAdjustment>=0 && alphaAdjustment<=256);
- assert(original!=null);
- this.alphaAdjustment = alphaAdjustment;
- this.desc = original;
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public ImageData getImageData() {
- ImageData orig = ImageCache.getInstance().getImage(desc).getImageData();
- ImageData id = new ImageData(orig.width, orig.height, orig.depth, orig.palette);
- id.setAlpha(0,0,0);
-
- if (orig.getTransparencyType()==SWT.TRANSPARENCY_ALPHA ||
- orig.getTransparencyType()==SWT.TRANSPARENCY_NONE)
- {
- for (int x=0; x