本文整理汇总了Java中org.eclipse.swt.graphics.ImageData.setAlpha方法的典型用法代码示例。如果您正苦于以下问题:Java ImageData.setAlpha方法的具体用法?Java ImageData.setAlpha怎么用?Java ImageData.setAlpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.ImageData
的用法示例。
在下文中一共展示了ImageData.setAlpha方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getControllerImage
import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
public Image getControllerImage(Display display) {
if(ctrlImage == null) {
ImageData img = new ImageData(48, 48, 32, RGB_PALETTE);
for(int y = 0; y < 40; y++)
for(int x = 0; x < 48; x++) {
int col = x / 6;
int row = y / 5;
int id = (row * 8) + col;
if(x % 6 < 5 && y % 5 < 4) {
img.setAlpha(x, y+4, 255);
if(id == this.id) img.setPixel(x, y+4, color.toARGB32());
else img.setPixel(x, y+4, 0x444444);
} else img.setAlpha(x, y+4, 0);
}
ctrlImage = new Image(display, img);
}
return ctrlImage;
}
示例2: rotate
import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
/**
* Rotate an image
* @param image the source
* @param direction : SWT.LEFT will rotate by 90 degrees on the left, SWT.RIGHT will rotate by 90 degrees on the right, SWT.DOWN will rotate by 180 degrees.
* @return the rotated image
*/
private Image rotate(Image image, int direction) {
ImageData srcData = image.getImageData();
int bytesPerPixel = srcData.bytesPerLine / srcData.width;
int destBytesPerLine = (direction == SWT.DOWN) ? srcData.width * bytesPerPixel : srcData.height * bytesPerPixel;
byte[] newData = new byte[srcData.data.length];
boolean isAlpha = srcData.alphaData != null;
byte[] newAlphaData = null;
if (isAlpha) {
newAlphaData = new byte[srcData.alphaData.length];
}
ImageData imgData =
new ImageData((direction == SWT.DOWN) ? srcData.width : srcData.height, (direction == SWT.DOWN) ? srcData.height : srcData.width, srcData.depth,
srcData.palette, destBytesPerLine, newData);
if (isAlpha) {
imgData.alphaData = newAlphaData;
}
imgData.alpha = srcData.alpha;
for (int srcY = 0; srcY < srcData.height; srcY++) {
for (int srcX = 0; srcX < srcData.width; srcX++) {
int destX = 0, destY = 0;
switch (direction) {
case SWT.LEFT: // left 90 degrees
destX = srcY;
destY = srcData.width - srcX - 1;
break;
case SWT.RIGHT: // right 90 degrees
destX = srcData.height - srcY - 1;
destY = srcX;
break;
case SWT.DOWN: // 180 degrees
destX = srcData.width - srcX - 1;
destY = srcData.height - srcY - 1;
break;
}
imgData.setPixel(destX, destY, srcData.getPixel(srcX, srcY));
if (isAlpha) {
imgData.setAlpha(destX, destY, srcData.getAlpha(srcX, srcY));
}
}
}
return new Image(image.getDevice(), imgData);
}