本文整理匯總了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;
}