本文整理汇总了Java中processing.core.PImage.ARGB属性的典型用法代码示例。如果您正苦于以下问题:Java PImage.ARGB属性的具体用法?Java PImage.ARGB怎么用?Java PImage.ARGB使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类processing.core.PImage
的用法示例。
在下文中一共展示了PImage.ARGB属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
Object top = stack.pop();
String data = top.toString();
if (!(top instanceof String) || !data.startsWith("data:image/")) {
throw new WarpScriptException(getName() + " expects a base64 data URI on top of the stack.");
}
data = data.substring(data.indexOf(",") + 1);
byte[] bytes = Base64.decodeBase64(data);
Image awtImage = new ImageIcon(bytes).getImage();
if (awtImage instanceof BufferedImage) {
BufferedImage buffImage = (BufferedImage) awtImage;
int space = buffImage.getColorModel().getColorSpace().getType();
if (space == ColorSpace.TYPE_CMYK) {
throw new WarpScriptException(getName() + " only supports RGB images.");
}
}
PImage image = new PImage(awtImage);
//
// Check transparency
//
if (null != image.pixels) {
for (int i = 0; i < image.pixels.length; i++) {
// since transparency is often at corners, hopefully this
// will find a non-transparent pixel quickly and exit
if ((image.pixels[i] & 0xff000000) != 0xff000000) {
image.format = PImage.ARGB;
break;
}
}
}
stack.push(image);
return stack;
}