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


Java BufferedImage.TYPE_INT_BGR属性代码示例

本文整理汇总了Java中java.awt.image.BufferedImage.TYPE_INT_BGR属性的典型用法代码示例。如果您正苦于以下问题:Java BufferedImage.TYPE_INT_BGR属性的具体用法?Java BufferedImage.TYPE_INT_BGR怎么用?Java BufferedImage.TYPE_INT_BGR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.image.BufferedImage的用法示例。


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

示例1: rotate180

/**
 * Rotates image 180 degrees.
 */
public void rotate180(){
    int width = bufferedImage.getWidth();
    int height = bufferedImage.getHeight();
    
    BufferedImage result = new BufferedImage(width, 
            height, BufferedImage.TYPE_INT_BGR);
    
    for (int x = 0; x < width; x ++) {
        for (int y = 0; y < height; y ++) {
            int rgb = bufferedImage.getRGB(x, y);
            result.setRGB(width-x-1, height-y-1, rgb); 
        }
    }
    
    bufferedImage = result;
    
}
 
开发者ID:ZiryLee,项目名称:FileUpload2Spring,代码行数:20,代码来源:EasyImage.java

示例2: genRandomCodeImage

/**
 * 生成随机图片
 */
public BufferedImage genRandomCodeImage(StringBuffer randomCode) {
	// BufferedImage类是具有缓冲区的Image类
	BufferedImage image = new BufferedImage(width, height,
			BufferedImage.TYPE_INT_BGR);
	// 获取Graphics对象,便于对图像进行各种绘制操作
	Graphics g = image.getGraphics();
	// 设置背景色
	// g.setColor(getRandColor(200, 250));
	g.fillRect(0, 0, width, height);

	// 设置干扰线的颜色
	g.setColor(getRandColor(110, 133));

	// 绘制干扰线
	for (int i = 0; i <= lineNum; i++) {
		drowLine(g);
	}
	// 绘制随机字符
	g.setFont(getRandomFont());
	for (int i = 1; i <= strNum; i++) {
		randomCode.append(drowString(g, i));
	}
	g.dispose();
	return image;
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:28,代码来源:Captcha.java

示例3: coerceToIntType

@SuppressWarnings("fallthrough")
public static BufferedImage coerceToIntType(BufferedImage img) {
  // ensure that img is a type which GeneralFilter can handle
  switch (img.getType()) {
  case BufferedImage.TYPE_INT_RGB:
  case BufferedImage.TYPE_INT_ARGB:
  case BufferedImage.TYPE_INT_ARGB_PRE:
  case BufferedImage.TYPE_INT_BGR:
    return img;
  default:
    return toType(img, img.getTransparency() == BufferedImage.OPAQUE ?
      BufferedImage.TYPE_INT_RGB :
      getCompatibleTranslucentImageType() == BufferedImage.TYPE_INT_ARGB ?
        BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_ARGB_PRE);
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:16,代码来源:ImageUtils.java

示例4: rotateRight

/**
 * Rotates image 90 degrees to the right.
 */
public void rotateRight(){
    int width = bufferedImage.getWidth();
    int height = bufferedImage.getHeight();
    
    BufferedImage result = new BufferedImage(height, 
            width, BufferedImage.TYPE_INT_BGR);
    
    for (int x = 0; x < width; x ++) {
        for (int y = 0; y < height; y ++) {
            int rgb = bufferedImage.getRGB(x, y);
            result.setRGB(height-y-1, x, rgb); 
        }
    }
    
    bufferedImage = result;
    
}
 
开发者ID:ZiryLee,项目名称:FileUpload2Spring,代码行数:20,代码来源:EasyImage.java

示例5: flipHorizontally

/**
 * Flips the image horizontally
 */
public void flipHorizontally(){
    int width = bufferedImage.getWidth();
    int height = bufferedImage.getHeight();
    
    BufferedImage result = new BufferedImage(width, 
            height, BufferedImage.TYPE_INT_BGR);
    
    for (int x = 0; x < width; x ++) {
        for (int y = 0; y < height; y ++) {
            int rgb = bufferedImage.getRGB(x, y);
            result.setRGB(width-x-1, y, rgb); 
        }
    }
    
    bufferedImage = result;
    
}
 
开发者ID:ZiryLee,项目名称:FileUpload2Spring,代码行数:20,代码来源:EasyImage.java

示例6: flipVertically

/**
 * Flips the image vertically.
 */
public void flipVertically(){
    int width = bufferedImage.getWidth();
    int height = bufferedImage.getHeight();
    
    BufferedImage result = new BufferedImage(width, 
            height, BufferedImage.TYPE_INT_BGR);
    
    for (int x = 0; x < width; x ++) {
        for (int y = 0; y < height; y ++) {
            int rgb = bufferedImage.getRGB(x, y);
            result.setRGB(x, height-y-1, rgb); 
        }
    }
    
    bufferedImage = result;
    
}
 
开发者ID:ZiryLee,项目名称:FileUpload2Spring,代码行数:20,代码来源:EasyImage.java

示例7: getImageTypeName

static String getImageTypeName(int type) {
    switch(type) {
        case BufferedImage.TYPE_INT_ARGB:
            return "TYPE_INT_ARGB";
        case BufferedImage.TYPE_INT_RGB:
            return "TYPE_INT_RGB";
        case BufferedImage.TYPE_INT_BGR:
            return "TYPE_INT_BGR";
        case BufferedImage.TYPE_INT_ARGB_PRE:
            return "TYPE_INT_ARGB_PRE";
        case BufferedImage.TYPE_3BYTE_BGR:
            return "TYPE_3BYTE_BGR";
        case BufferedImage.TYPE_4BYTE_ABGR:
            return "TYPE_4BYTE_ABGR";
        case BufferedImage.TYPE_4BYTE_ABGR_PRE:
            return "TYPE_4BYTE_ABGR_PRE";
        case BufferedImage.TYPE_BYTE_BINARY:
            return "TYPE_BYTE_BINARY";
        case BufferedImage.TYPE_BYTE_GRAY:
            return "TYPE_BYTE_GRAY";
        case BufferedImage.TYPE_BYTE_INDEXED:
            return "TYPE_BYTE_INDEXED";
        case BufferedImage.TYPE_USHORT_555_RGB:
            return "TYPE_USHORT_555_RGB";
        case BufferedImage.TYPE_USHORT_565_RGB:
            return "TYPE_USHORT_565_RGB";
        case BufferedImage.TYPE_USHORT_GRAY:
            return "TYPE_USHORT_GRAY";
    }
    return "UNKNOWN";
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:ColConvTest.java

示例8: describeType

private static String describeType(int type) {
    switch(type) {
    case BufferedImage.TYPE_3BYTE_BGR:
        return "TYPE_3BYTE_BGR";
    case BufferedImage.TYPE_4BYTE_ABGR:
        return "TYPE_4BYTE_ABGR";
    case BufferedImage.TYPE_BYTE_GRAY:
        return "TYPE_BYTE_GRAY";
    case BufferedImage.TYPE_INT_ARGB:
        return "TYPE_INT_ARGB";
    case BufferedImage.TYPE_INT_BGR:
        return  "TYPE_INT_BGR";
    case BufferedImage.TYPE_INT_RGB:
        return "TYPE_INT_RGB";
    case BufferedImage.TYPE_BYTE_INDEXED:
        return "TYPE_BYTE_INDEXED";
    default:
        throw new RuntimeException("Test FAILED: unknown type " + type);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:OpCompatibleImageTest.java

示例9: FormattingPicture

public static BufferedImage FormattingPicture(BufferedImage imageIn) {

		BufferedImage image = new BufferedImage(854, 480, BufferedImage.TYPE_INT_BGR);
		Graphics2D g = (Graphics2D) image.getGraphics();
		g.drawImage(imageIn, 0, 0, 854, 480, null);
		return image;
	}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:7,代码来源:PictureFactory.java

示例10: exportAsImage

/**
 * Export the current graph as image by using specified parameters. 
 *
 * @param vv the VisualizationViewer
 * @param file the current file to export to
 */
private void exportAsImage(BasicGraphGuiVisViewer<GraphNode, GraphEdge> vv, String path2File, String extension) {

	// --- If the VisualizationViewer is null ---------
	if (vv == null) {
		return;
	}
	// --- Overwrite existing file ? ------------------
	File writeFile = new File(path2File);
	if (writeFile.exists()) {
		String msgHead = "Overwrite?";
		String msgText = "Overwrite existing file?";
		int msgAnswer = JOptionPane.showInternalConfirmDialog(this, msgText, msgHead, JOptionPane.YES_NO_OPTION);
		if (msgAnswer == JOptionPane.NO_OPTION) {
			return;
		}
	}

	// --- Lets go ! ----------------------------------
	int width = vv.getSize().width;
	int height = vv.getSize().height;

	BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
	Graphics2D graphics = bi.createGraphics();
	graphics.fillRect(0, 0, width, height);

	boolean wasDoubleBuffered=vv.isDoubleBuffered();
	vv.setDoubleBuffered(false);
	vv.paint(graphics);
	vv.paintComponents(graphics);
	vv.setDoubleBuffered(wasDoubleBuffered);

	try {
		ImageIO.write(bi, extension, writeFile);

	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:45,代码来源:BasicGraphGui.java

示例11: getImageTypeName

private String getImageTypeName(int t) {
    switch(t) {
      case BufferedImage.TYPE_INT_RGB:
          return "TYPE_INT_RGB";
      case BufferedImage.TYPE_INT_BGR:
          return "TYPE_INT_BGR";
      case TYPE_INT_GRB:
          return "TYPE_INT_GRB";
      case TYPE_INT_GBR:
          return "TYPE_INT_GBR";
      case TYPE_INT_RBG:
          return "TYPE_INT_RBG";
      case TYPE_INT_BRG:
          return "TYPE_INT_BRG";
      case BufferedImage.TYPE_USHORT_555_RGB:
          return "TYPE_USHORT_555_RGB";
      case BufferedImage.TYPE_USHORT_565_RGB:
          return "TYPE_USHORT_565_RGB";
      case TYPE_USHORT_555_GRB:
          return "TYPE_USHORT_555_GRB";
      case TYPE_USHORT_555_BGR:
          return "TYPE_USHORT_555_BGR";
      case TYPE_USHORT_565_BGR:
          return "TYPE_USHORT_565_BGR";
      case BufferedImage.TYPE_3BYTE_BGR:
          return "TYPE_3BYTE_BGR";
      case TYPE_3BYTE_RGB:
          return "TYPE_3BYTE_RGB";
      case TYPE_3BYTE_GRB:
          return "TYPE_3BYTE_GRB";
      case BufferedImage.TYPE_BYTE_INDEXED:
          return "TYPE_BYTE_INDEXED";
      case TYPE_4BPP_INDEXED:
          return "TYPE_BYTE_INDEXED (4bpp)";
      default:
          throw new IllegalArgumentException("Unknown image type: " + t);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:BMPSubsamplingTest.java

示例12: crop

public void crop(int startX, int startY, int endX, int endY){
    int width = bufferedImage.getWidth();
    int height = bufferedImage.getHeight();
    
    if(startX == -1){
        startX = 0;
    }
    
    if(startY == -1){
        startY = 0;
    }
    
    if(endX == -1){
        endX = width-1;
    }
    
    if(endY == -1){
        endY = height-1;
    }
    
    /*
     * 2017-03-23:ziry
     * 旧版本endY-startY+1,endX-startX+1有黑边
     * BufferedImage result = new BufferedImage(endX-startX+1, endY-startY+1, BufferedImage.TYPE_INT_BGR);
     */
    BufferedImage result = new BufferedImage(endX-startX, endY-startY, BufferedImage.TYPE_INT_BGR);
    
    for (int y = startY; y < endY; y ++) {
        for (int x = startX; x < endX; x ++) {
            int rgb = bufferedImage.getRGB(x, y);
            result.setRGB(x-startX, y-startY, rgb); 
        }
    }
    bufferedImage = result;
}
 
开发者ID:ZiryLee,项目名称:FileUpload2Spring,代码行数:35,代码来源:EasyImage.java

示例13: convertImage

/**
 * this method convert supplied image to suitable type
 * it is needed because we need bytes of array so TYPE_INT images must be
 * converted to BYTE_BGR or so
 * @param originalImage loaded from file-chooser
 * @return 
 */

public BufferedImage convertImage(BufferedImage originalImage) {
    int newImageType = originalImage.getType();
    
    /**
     * Converting int to byte since byte array is needed later to modify 
     * the image
     */
    if (newImageType == BufferedImage.TYPE_INT_RGB
            || newImageType == BufferedImage.TYPE_INT_BGR) {
        newImageType = BufferedImage.TYPE_3BYTE_BGR;
    } else if (newImageType == BufferedImage.TYPE_INT_ARGB ||
            newImageType == BufferedImage.TYPE_CUSTOM) {
        newImageType = BufferedImage.TYPE_4BYTE_ABGR;
    } else if (newImageType == BufferedImage.TYPE_INT_ARGB_PRE) {
        newImageType = BufferedImage.TYPE_4BYTE_ABGR_PRE;
    } else {
        // no need to convert original image
        return null;
    }
    BufferedImage newImage = new BufferedImage(originalImage.getWidth(), 
            originalImage.getHeight(), newImageType);
    Graphics g = newImage.getGraphics();
    g.drawImage(originalImage, 0, 0, null);
    g.dispose();
    return newImage;
}
 
开发者ID:varunon9,项目名称:Image-Stegano,代码行数:34,代码来源:ImageUtility.java

示例14: setImageSize

public void setImageSize(int sizeX, int sizeY) {
		if (sizeX != this.sizeX || sizeY != this.sizeY) {
			this.sizeX = sizeX;
			this.sizeY = sizeY;
			if (this.sizeX < 0)
				this.sizeX = 0;
			if (this.sizeY < 0)
				this.sizeY = 0;
//			this.pixmap = new Color[this.sizeX][this.sizeY];
			if (sizeX > 0 && sizeY > 0)
				this.image = new BufferedImage(this.sizeX, this.sizeY, BufferedImage.TYPE_INT_RGB);
			else 
				this.image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_BGR);
		}
	}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:15,代码来源:NonGLImageDisplay.java

示例15: main

public static void main(String[] args) throws IOException {
    // buffered image types listed below can be saved as BI_BITFIELDS BMP
    int[] types = {BufferedImage.TYPE_3BYTE_BGR,
                   BufferedImage.TYPE_USHORT_555_RGB,
                   BufferedImage.TYPE_USHORT_565_RGB,
                   BufferedImage.TYPE_BYTE_GRAY,
                   BufferedImage.TYPE_BYTE_BINARY,
                   BufferedImage.TYPE_BYTE_INDEXED,
                   BufferedImage.TYPE_INT_BGR,
                   BufferedImage.TYPE_INT_RGB};

    for (int i = 0; i < types.length; i++) {
        System.out.println("Test image " + types[i]);
        TestCompressionBI_BITFIELDS t = new TestCompressionBI_BITFIELDS();

        BufferedImage src =
            t.createTestImage(types[i]);
        System.out.println("Image for test: " + src);
        System.out.println("SampleModel: " + src.getSampleModel());

        BufferedImage dst = null;
        try {
            dst = t.writeAndRead(src);
        } catch (IOException e) {
            e.printStackTrace(System.out);
        }


        t.compareImages(src, dst);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:TestCompressionBI_BITFIELDS.java


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