当前位置: 首页>>代码示例>>Java>>正文


Java ImageData.setPixel方法代码示例

本文整理汇总了Java中org.eclipse.swt.graphics.ImageData.setPixel方法的典型用法代码示例。如果您正苦于以下问题:Java ImageData.setPixel方法的具体用法?Java ImageData.setPixel怎么用?Java ImageData.setPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.graphics.ImageData的用法示例。


在下文中一共展示了ImageData.setPixel方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getImageData

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
protected ImageData getImageData() {
	int[][] a = (int[][]) array;
	ImageData data = new ImageData(width, height, 24, palette);
	for(int y = 0; y < height; y++) {
		for(int x = 0; x < width; x++) {
			int v = a[y][x];
			int r = (v >> 16) & 0xFF;
			int g = (v >> 8) & 0xFF;
			int b = v & 0xFF;

			int pixel = 0;
			if(valid(r, g, b)) {
				pixel |= (redShift < 0 ? r << -redShift : r >>> redShift) & redMask;
				pixel |= (greenShift < 0 ? g << -greenShift : g >>> greenShift) & greenMask;
				pixel |= (blueShift < 0 ? b << -blueShift : b >>> blueShift) & blueMask;
			}
			//					int pixel = valid(r,g,b) ? palette.getPixel(new RGB(r,g,b)) : palette.getPixel(new RGB(255, 0, 0));
			data.setPixel(x, y, pixel);
		}
	}
	return data;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:23,代码来源:ColorImageWidget.java

示例2: applyTransparency

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
public void applyTransparency( TGColor background ){
	RGB alpha = new RGB( background.getRed(), background.getGreen(), background.getBlue() );
	RGB none = new RGB((0xff ^ alpha.red),(0xff ^ alpha.green),(0xff ^ alpha.blue));
	
	Image srcImage = this.handle;
	ImageData srcData = srcImage.getImageData();
	ImageData maskData = new ImageData(srcData.width,srcData.height,1,new PaletteData(new RGB[]{ none,alpha }  ));
	for(int x = 0; x< maskData.width; x++) {
		for(int y = 0; y < maskData.height; y++) {
			RGB rgb = srcData.palette.getRGB(srcData.getPixel(x, y));
			if(rgb.red == alpha.red && rgb.green == alpha.green && rgb.blue == alpha.blue){
				maskData.setPixel(x, y, maskData.palette.getPixel(none));
			}else{
				maskData.setPixel(x, y, maskData.palette.getPixel(alpha));
			}
		}
	}
	this.handle = new Image(srcImage.getDevice(),srcData,maskData);
	
	srcImage.dispose();
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:22,代码来源:TGImageImpl.java

示例3: getControllerImage

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
public Image getControllerImage(Display display) {
	if(ctrlImage == null) {
		ImageData img = new ImageData(48, 48, 32, RGB_PALETTE);
		for(int y = 0; y < 40; y++)
			for(int x = 0; x < 48; x++) {
				int col = x / 6;
				int row = y / 5;
				int id  = (row * 8) + col; 
				if(x % 6 < 5 && y % 5 < 4) {
					img.setAlpha(x, y+4, 255);
					if(id == this.id)	img.setPixel(x, y+4, color.toARGB32());
					else				img.setPixel(x, y+4, 0x444444);
				} else img.setAlpha(x, y+4, 0);
			}
		ctrlImage = new Image(display, img);
	}
	return ctrlImage;
}
 
开发者ID:arisona,项目名称:ether,代码行数:19,代码来源:Bouncelet.java

示例4: getImageData

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
protected ImageData getImageData() {
	int[][] a = (int[][]) array;
	ImageData data = new ImageData(width, height, 8, grayscalePalette);
	for(int y = 0; y < height; y++) {
		for(int x = 0; x < width && x < width; x++)
			data.setPixel(x, y, valid(a[y][x]) ? a[y][x] : 0);
	}
	return data;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:10,代码来源:GrayscaleImageWidget.java

示例5: getImageData

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
protected ImageData getImageData() {
	boolean[][] a = (boolean[][]) array;
	ImageData data = new ImageData(width, height, 1, binaryPalette);
	for(int y = 0; y < height; y++)
		for(int x = 0; x < width && x < width; x++)
			data.setPixel(x, y, a[y][x] ? 0 : 1);
	return data;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:9,代码来源:BinaryImageWidget.java

示例6: applyMask

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
/**
 * Crea una mascara a partir de src.
 * 
 * @param src
 * @param alpha
 * @param none
 * @return ImageData
 */
public static ImageData applyMask(ImageData src,RGB alpha,RGB none){
	ImageData maskData = new ImageData(src.width,src.height,1,new PaletteData(new RGB[]{ none,alpha }  ));
	for(int x = 0; x< maskData.width; x++) {
		for(int y = 0; y < maskData.height; y++) {
			RGB rgb = src.palette.getRGB(src.getPixel(x, y));
			if(rgb.red == alpha.red && rgb.green == alpha.green && rgb.blue == alpha.blue){
				maskData.setPixel(x, y, maskData.palette.getPixel(none));
			}else{
				maskData.setPixel(x, y, maskData.palette.getPixel(alpha));
			}
		}
	}
	return maskData;
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:23,代码来源:ImageUtils.java

示例7: setBrightness

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
private static void setBrightness() {
        if (image.isDisposed()) {
            return;
        }

        final ImageData imageData = image.getImageData();

        for (int x = 0; x < imageData.width; x++) {
            for (int y = 0; y < imageData.height; y++) {
                final RGB rgb = imageData.palette.getRGB(imageData.getPixel(x, y));
                final float[] hsb = rgb.getHSB();

                hsb[2] = hsb[2] + 0.1f;
                if (hsb[2] > 1.0f) {
                    hsb[2] = 1.0f;
                }

//				hsb[1] = hsb[1] - 0.1f;
//				if (hsb[1] < 0.0f) {
//					hsb[1] = 0.0f;
//				}
                final RGB newRGB = new RGB(hsb[0], hsb[1], hsb[2]);

                final int pixel = imageData.palette.getPixel(newRGB);
                imageData.setPixel(x, y, pixel);
            }
        }

        image.dispose();
        image = new Image(Display.getDefault(), imageData);

        imageFigure.setImage(image);
    }
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:34,代码来源:ImageTest.java

示例8: multScalar

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
/**
	 * Multiplies all pixels of the given ImageData with the given scalar factor
	 * and returns a new image data
	 */
	public static ImageData multScalar(ImageData data, double factor, boolean inPlace) {
		ImageData newImageData = inPlace ? data : 
				new ImageData (data.width, data.height, 24, new PaletteData (0xFF, 0xFF00, 0xFF0000));
		
		final int w = data.width;
		final int h = data.height;
	
		for (int x=0; x<w; ++x) {
			for (int y=0; y<h; ++y) {
				int p = data.getPixel(x, y);
				
				RGB rgb = data.palette.getRGB(p);
				
//				System.out.println("rgb = "+rgb);
				
				rgb.red = CoreUtils.bound(rgb.red *= factor, 0, 255);
				rgb.green = CoreUtils.bound(rgb.green *= factor, 0, 255);
				rgb.blue = CoreUtils.bound(rgb.blue *= factor, 0, 255);
				
//				rgb.red = CoreUtils.bound((int) Math.pow(rgb.red, gamma), 0, 255);
//				rgb.green = CoreUtils.bound((int) Math.pow(rgb.green, gamma), 0, 255);
//				rgb.blue = CoreUtils.bound((int) Math.pow(rgb.blue, gamma), 0, 255);
				
//				System.out.println("rgb2 = "+rgb);
				newImageData.setPixel(x, y, newImageData.palette.getPixel(rgb));
			}
		}
		
		return newImageData;
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:35,代码来源:SWTUtil.java

示例9: setBrightness

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
private static void setBrightness() {
		if (image.isDisposed()) {
			return;
		}

		ImageData imageData = image.getImageData();

		for (int x = 0; x < imageData.width; x++) {
			for (int y = 0; y < imageData.height; y++) {
				RGB rgb = imageData.palette.getRGB(imageData.getPixel(x, y));
				float[] hsb = rgb.getHSB();

				hsb[2] = hsb[2] + 0.1f;
				if (hsb[2] > 1.0f) {
					hsb[2] = 1.0f;
				}
				
//				hsb[1] = hsb[1] - 0.1f;
//				if (hsb[1] < 0.0f) {
//					hsb[1] = 0.0f;
//				}
				RGB newRGB = new RGB(hsb[0], hsb[1], hsb[2]);

				
				int pixel = imageData.palette.getPixel(newRGB);
				imageData.setPixel(x, y, pixel);
			}
		}

		image.dispose();
		image = new Image(Display.getDefault(), imageData);

		imageFigure.setImage(image);
	}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:35,代码来源:ImageTest.java

示例10: rotate

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
/**
 * Rotate an image
 * @param image the source
 * @param direction : SWT.LEFT will rotate by 90 degrees on the left, SWT.RIGHT will rotate by 90 degrees on the right, SWT.DOWN will rotate by 180 degrees.
 * @return the rotated image
 */
private Image rotate(Image image, int direction) {
  ImageData srcData = image.getImageData();
  int bytesPerPixel = srcData.bytesPerLine / srcData.width;
  int destBytesPerLine = (direction == SWT.DOWN) ? srcData.width * bytesPerPixel : srcData.height * bytesPerPixel;
  byte[] newData = new byte[srcData.data.length];

  boolean isAlpha = srcData.alphaData != null;
  byte[] newAlphaData = null;

  if (isAlpha) {
    newAlphaData = new byte[srcData.alphaData.length];
  }
  ImageData imgData =
      new ImageData((direction == SWT.DOWN) ? srcData.width : srcData.height, (direction == SWT.DOWN) ? srcData.height : srcData.width, srcData.depth,
          srcData.palette, destBytesPerLine, newData);
  if (isAlpha) {
    imgData.alphaData = newAlphaData;
  }
  imgData.alpha = srcData.alpha;

  for (int srcY = 0; srcY < srcData.height; srcY++) {
    for (int srcX = 0; srcX < srcData.width; srcX++) {
      int destX = 0, destY = 0;

      switch (direction) {
        case SWT.LEFT: // left 90 degrees
          destX = srcY;
          destY = srcData.width - srcX - 1;
        break;
        case SWT.RIGHT: // right 90 degrees
          destX = srcData.height - srcY - 1;
          destY = srcX;
        break;
        case SWT.DOWN: // 180 degrees
          destX = srcData.width - srcX - 1;
          destY = srcData.height - srcY - 1;
        break;
      }

      imgData.setPixel(destX, destY, srcData.getPixel(srcX, srcY));
      if (isAlpha) {
        imgData.setAlpha(destX, destY, srcData.getAlpha(srcX, srcY));
      }
    }
  }

  return new Image(image.getDevice(), imgData);
}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:55,代码来源:RotativeWorkspaceImageFigure.java

示例11: changeImage

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
private void changeImage() {
    final InsertedImage model = (InsertedImage) getModel();

    final ImageData newImageData = new ImageData(imageData.width, imageData.height, imageData.depth, imageData.palette);

    for (int x = 0; x < imageData.width; x++) {
        for (int y = 0; y < imageData.height; y++) {
            final RGB rgb = imageData.palette.getRGB(imageData.getPixel(x, y));
            final float[] hsb = rgb.getHSB();

            if (model.getHue() != 0) {
                hsb[0] = model.getHue() & 360;
            }

            hsb[1] = hsb[1] + (model.getSaturation() / 100f);
            if (hsb[1] > 1.0f) {
                hsb[1] = 1.0f;
            } else if (hsb[1] < 0) {
                hsb[1] = 0f;
            }

            hsb[2] = hsb[2] + (model.getBrightness() / 100f);
            if (hsb[2] > 1.0f) {
                hsb[2] = 1.0f;

            } else if (hsb[2] < 0) {
                hsb[2] = 0f;
            }

            final RGB newRGB = new RGB(hsb[0], hsb[1], hsb[2]);

            final int pixel = imageData.palette.getPixel(newRGB);

            newImageData.setPixel(x, y, pixel);
        }
    }

    if (image != null && !image.isDisposed()) {
        image.dispose();
    }

    image = new Image(Display.getDefault(), newImageData);
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:44,代码来源:InsertedImageEditPart.java

示例12: changeImage

import org.eclipse.swt.graphics.ImageData; //导入方法依赖的package包/类
private void changeImage() {
	InsertedImage model = (InsertedImage) this.getModel();

	ImageData newImageData = new ImageData(this.imageData.width,
			this.imageData.height, this.imageData.depth,
			this.imageData.palette);

	for (int x = 0; x < this.imageData.width; x++) {
		for (int y = 0; y < this.imageData.height; y++) {
			RGB rgb = this.imageData.palette.getRGB(this.imageData
					.getPixel(x, y));
			float[] hsb = rgb.getHSB();

			if (model.getHue() != 0) {
				hsb[0] = model.getHue() & 360;
			}

			hsb[1] = hsb[1] + (model.getSaturation() / 100f);
			if (hsb[1] > 1.0f) {
				hsb[1] = 1.0f;
			} else if (hsb[1] < 0) {
				hsb[1] = 0f;
			}

			hsb[2] = hsb[2] + (model.getBrightness() / 100f);
			if (hsb[2] > 1.0f) {
				hsb[2] = 1.0f;

			} else if (hsb[2] < 0) {
				hsb[2] = 0f;
			}

			RGB newRGB = new RGB(hsb[0], hsb[1], hsb[2]);

			int pixel = imageData.palette.getPixel(newRGB);

			newImageData.setPixel(x, y, pixel);
		}
	}

	if (this.image != null && !this.image.isDisposed()) {
		this.image.dispose();
	}

	this.image = new Image(Display.getDefault(), newImageData);
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:47,代码来源:InsertedImageEditPart.java


注:本文中的org.eclipse.swt.graphics.ImageData.setPixel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。