本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.createImageData方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.createImageData方法的具體用法?Java Context2d.createImageData怎麽用?Java Context2d.createImageData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.canvas.dom.client.Context2d
的用法示例。
在下文中一共展示了Context2d.createImageData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createCanvas
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public static Canvas createCanvas(int [] pixels, int width, int height) {
Canvas canvas = Canvas.createIfSupported();
if(canvas == null) return null;
canvas.setCoordinateSpaceWidth(width);
canvas.setCoordinateSpaceHeight(height);
Context2d context = canvas.getContext2d();
ImageData data = context.createImageData(width, height);
CanvasPixelArray array = data.getData();
for(int i=0; i<width*height; i++) { // ABGR
array.set(4*i+0, pixels[i] & 0xFF);
array.set(4*i+1, (pixels[i] >> 8) & 0xFF);
array.set(4*i+2, (pixels[i] >> 16) & 0xFF);
array.set(4*i+3, (pixels[i] >> 24) & 0xFF);
}
context.putImageData(data, 0, 0);
return canvas;
}
示例2: createImageCanvas
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
Canvas createImageCanvas(int [] pixels, int width, int height) {
Canvas canvas = Canvas.createIfSupported();
canvas.setCoordinateSpaceWidth(width);
canvas.setCoordinateSpaceHeight(height);
Context2d context = canvas.getContext2d();
ImageData data = context.createImageData(width, height);
CanvasPixelArray array = data.getData();
for(int i=0; i<width*height; i++) {
array.set(4*i+0, pixels[i] & 0xFF);
array.set(4*i+1, (pixels[i] >> 8) & 0xFF);
array.set(4*i+2, (pixels[i] >> 16) & 0xFF);
array.set(4*i+3, (pixels[i] >> 24) & 0xFF);
}
context.putImageData(data, 0, 0);
return canvas;
}
示例3: createImageCanvas
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private Canvas createImageCanvas(int [] pixels, int width, int height) {
Canvas canvas = Canvas.createIfSupported();
canvas.setCoordinateSpaceWidth(width);
canvas.setCoordinateSpaceHeight(height);
Context2d context = canvas.getContext2d();
ImageData data = context.createImageData(width, height);
CanvasPixelArray array = data.getData();
for(int i=0; i<width*height; i++) { // ABGR
array.set(4*i+0, pixels[i] & 0xFF);
array.set(4*i+1, (pixels[i] >> 8) & 0xFF);
array.set(4*i+2, (pixels[i] >> 16) & 0xFF);
array.set(4*i+3, (pixels[i] >> 24) & 0xFF);
}
context.putImageData(data, 0, 0);
canvas.getElement().getStyle().setMargin(4, Unit.PX);
return canvas;
}
示例4: setRgb
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override public void setRgb(int startX, int startY, int width, int height,
int[] rgbArray, int offset, int scanSize) {
Context2d ctx = canvas.getContext2d();
ImageData imageData = ctx.createImageData(width, height);
CanvasPixelArray pixelData = imageData.getData();
int i = 0;
int dst = offset;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x ++) {
int argb = rgbArray[dst + x];
pixelData.set(i++, (argb >> 16) & 255);
pixelData.set(i++, (argb >> 8) & 255);
pixelData.set(i++, (argb) & 255);
pixelData.set(i++, (argb >> 24) & 255);
}
dst += scanSize;
}
ctx.putImageData(imageData, startX, startY);
}