本文整理汇总了Java中com.google.gwt.canvas.dom.client.ImageData.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java ImageData.getWidth方法的具体用法?Java ImageData.getWidth怎么用?Java ImageData.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.canvas.dom.client.ImageData
的用法示例。
在下文中一共展示了ImageData.getWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMaskBySimilarColor
import com.google.gwt.canvas.dom.client.ImageData; //导入方法依赖的package包/类
/**
*
* @param data
* @param r
* @param g
* @param b
* @param maxLength
* @return imageData-width x imageData-height length (if similar value is 1,or 0)
*/
public static Uint8Array createMaskBySimilarColor(ImageData data,int r,int g,int b,int maxLength){
Uint8Array bytes=Uint8Array.createUint8(data.getWidth()*data.getHeight());
for(int y=0;y<data.getHeight();y++){
for(int x=0;x<data.getWidth();x++){
int imgR=data.getRedAt(x, y);
int imgG=data.getGreenAt(x, y);
int imgB=data.getBlueAt(x, y);
double length=ColorUtils.getColorLength(r, g, b, imgR, imgG, imgB);
if(length<maxLength){
bytes.set(y*data.getWidth()+x, 1);
}
}
}
return bytes;
}
示例2: createMaskByColor
import com.google.gwt.canvas.dom.client.ImageData; //导入方法依赖的package包/类
public static Uint8Array createMaskByColor(ImageData data,int r,int g,int b,boolean setSameColorCase){
Uint8Array bytes=Uint8Array.createUint8(data.getWidth()*data.getHeight());
for(int y=0;y<data.getHeight();y++){
for(int x=0;x<data.getWidth();x++){
int imgR=data.getRedAt(x, y);
int imgG=data.getGreenAt(x, y);
int imgB=data.getBlueAt(x, y);
if(r==imgR && g==imgG&&b==imgB){
if(setSameColorCase){
bytes.set(y*data.getWidth()+x, 1);
}
}else{
if(!setSameColorCase){
bytes.set(y*data.getWidth()+x, 1);
}
}
}
}
return bytes;
}
示例3: getTransparentArea
import com.google.gwt.canvas.dom.client.ImageData; //导入方法依赖的package包/类
public Rect getTransparentArea(int transparentValue,int expandW,int expandH){
int minX=canvas.getCoordinateSpaceWidth();
int minY=canvas.getCoordinateSpaceHeight();
int maxX=0;
int maxY=0;
ImageData data=canvas.getContext2d().getImageData(0, 0, canvas.getCoordinateSpaceWidth(), canvas.getCoordinateSpaceHeight());
for(int x=1;x<data.getWidth();x++){
for(int y=1;y<data.getHeight();y++){
int alpha=data.getAlphaAt(x, y);
if(alpha<=transparentValue){
if(minX>x){
minX=x;
}
if(minY>y){
minY=y;
}
if(maxX<x){
maxX=x;
}
if(maxY<y){
maxY=y;
}
}
}
}
if(minX<=maxX && minY<=maxY){
return new Rect(minX,minY,maxX-minX,maxY-minY).expandIn(expandW, expandH, data.getWidth(), data.getHeight());
}else{
return new Rect(0,0,0,0);//invalid case.
}
}
示例4: FourWayImageDataQueueFloodFill
import com.google.gwt.canvas.dom.client.ImageData; //导入方法依赖的package包/类
public FourWayImageDataQueueFloodFill(ImageData imageData, int x, int y, Colour srcColour, Colour tgtColour) {
this.imageData = imageData;
this.width = imageData.getWidth();
this.height = imageData.getHeight();
this.mark = new boolean[this.width][this.height];
this.srcColour = srcColour;
this.tgtColour = tgtColour;
this.queue = new LinkedList<Point>();
queue.add(new Point(x, y));
}