当前位置: 首页>>代码示例>>Java>>正文


Java SWT.TRANSPARENCY_PIXEL属性代码示例

本文整理汇总了Java中org.eclipse.swt.SWT.TRANSPARENCY_PIXEL属性的典型用法代码示例。如果您正苦于以下问题:Java SWT.TRANSPARENCY_PIXEL属性的具体用法?Java SWT.TRANSPARENCY_PIXEL怎么用?Java SWT.TRANSPARENCY_PIXEL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.swt.SWT的用法示例。


在下文中一共展示了SWT.TRANSPARENCY_PIXEL属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: autoScaleImageData

private static ImageData autoScaleImageData(Device device, final ImageData imageData, float scaleFactor) {
	int width = imageData.width;
	int height = imageData.height;
	int scaledWidth = Math.round(width * scaleFactor);
	int scaledHeight = Math.round(height * scaleFactor);


	ImageData imageMaskData = null;

	if (imageData.getTransparencyType() == SWT.TRANSPARENCY_ALPHA) {
		imageMaskData = new ImageData(width, height, 8, ALPHA_PALETTE, 0, imageData.alphaData);
	} else if (imageData.getTransparencyType() == SWT.TRANSPARENCY_PIXEL || imageData.getTransparencyType() == SWT.TRANSPARENCY_MASK) {
		ImageData transparencyMaskData = imageData.getTransparencyMask();
		imageMaskData = new ImageData(width, height, 1, BW_PALETTE, transparencyMaskData.scanlinePad, transparencyMaskData.data);
	}

	Image original = new Image(device, imageData);
	Image originalMask = null;

	if (imageMaskData != null) {
		originalMask = new Image(device, imageMaskData);
	}

	/* Create a 24 bit image data with alpha channel */
	ImageData resultData = new ImageData(scaledWidth, scaledHeight, 24, new PaletteData(0xFF, 0xFF00, 0xFF0000));
	ImageData resultMaskData = null;

	if (imageMaskData != null) {
		resultMaskData = new ImageData(scaledWidth, scaledHeight, imageMaskData.depth, imageMaskData.palette);
	}

	Image result = new Image(device, resultData);
	Image resultMask = null;

	GC gc = new GC(result);
	gc.setAntialias(SWT.ON);
	gc.drawImage(original, 0, 0, width, height, 0, 0, scaledWidth, scaledHeight);
	gc.dispose();

	if (resultMaskData != null) {
		resultMask = new Image(device, resultMaskData);
		gc = new GC(resultMask);
		gc.setAntialias(SWT.ON);
		gc.drawImage(originalMask, 0, 0, width, height, 0, 0, scaledWidth, scaledHeight);
		gc.dispose();
	}

	original.dispose();
	originalMask.dispose();

	ImageData scaledResult = result.getImageData();

	if (resultMask != null) {
		ImageData scaledResultMaskData = resultMask.getImageData();

		// Convert 1-bit mask
		if (scaledResultMaskData.depth == 1) {
			scaledResult.maskPad = scaledResultMaskData.scanlinePad;
			scaledResult.maskData = scaledResultMaskData.data;
		} else {
			scaledResult.alphaData = scaledResultMaskData.data;
		}
	}

	result.dispose();
	resultMask.dispose();
	return scaledResult;
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:68,代码来源:Utils.java


注:本文中的org.eclipse.swt.SWT.TRANSPARENCY_PIXEL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。