當前位置: 首頁>>代碼示例>>Java>>正文


Java Context2d.createImageData方法代碼示例

本文整理匯總了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;
	
}
 
開發者ID:npedotnet,項目名稱:npe-image-library,代碼行數:25,代碼來源:GwtImageReader.java

示例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;

	}
 
開發者ID:npedotnet,項目名稱:TGAReader,代碼行數:22,代碼來源:TexturedCube.java

示例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;
	
}
 
開發者ID:npedotnet,項目名稱:TGAReader,代碼行數:24,代碼來源:ImageCanvasTest.java

示例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);
}
 
開發者ID:playn,項目名稱:playn,代碼行數:20,代碼來源:HtmlImage.java


注:本文中的com.google.gwt.canvas.dom.client.Context2d.createImageData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。