List of usage examples for java.awt.image BufferedImage TYPE_INT_RGB
int TYPE_INT_RGB
To view the source code for java.awt.image BufferedImage TYPE_INT_RGB.
Click Source Link
From source file:com.seleniumtests.util.imaging.ImageProcessor.java
/** * Agregate 2 pictures// w ww. j a va 2 s . c om * @param imgf1 first picture to agregate * @param imgf2 seconde picture to aggregate * @param img2PosX X coord where second picture will be but, relative to first one * @param img2PosY Y coord where second picture will be but, relative to first one * @return the complete picture */ public static BufferedImage concat(BufferedImage img1, BufferedImage img2, Integer img2PosX, Integer img2PosY) { if (img2PosX < 0 || img2PosY < 0) { throw new IllegalArgumentException("relative position must be > 0"); } Integer finalWidth = Math.max(img2.getWidth() + img2PosX, img1.getWidth()); Integer finalHeight = Math.max(img2.getHeight() + img2PosY, img1.getHeight()); BufferedImage img = new BufferedImage(finalWidth, finalHeight, BufferedImage.TYPE_INT_RGB); img.createGraphics().drawImage(img1, 0, 0, null); img.createGraphics().drawImage(img2, img2PosX, img2PosY, null); return img; }
From source file:MultiTextureTest.java
public Texture createLightMap() { int width = 128; int height = 128; BufferedImage bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); int[] rgbArray = new int[width * height]; int index, index2; int rgbInc = 256 / (width / 2 - 20); int rgbValue = 0; int k = width / 2 - 5; int i, j, rgb; rgb = 0xff;/* w w w.j a v a 2s . c om*/ rgbValue = rgb | (rgb << 8) | (rgb << 16) | (rgb << 24); for (i = width / 2 - 1, j = 0; j < 10; j++, i--) { rgbArray[i] = rgbValue; } for (; i > 8; i--, rgb -= rgbInc) { rgbValue = rgb | (rgb << 8) | (rgb << 16) | (rgb << 24); rgbArray[i] = rgbValue; } for (; i >= 0; i--) { rgbArray[i] = rgbValue; } for (i = 0; i < width / 2; i++) { rgbValue = rgbArray[i]; index = i; index2 = (width - i - 1); for (j = 0; j < height; j++) { rgbArray[index] = rgbArray[index2] = rgbValue; index += width; index2 += width; } } bimage.setRGB(0, 0, width, height, rgbArray, 0, width); ImageComponent2D grayImage = new ImageComponent2D(ImageComponent.FORMAT_RGB, bimage); lightTex = new Texture2D(Texture.BASE_LEVEL, Texture.RGB, width, height); lightTex.setImage(0, grayImage); return lightTex; }
From source file:doge.photo.DogePhotoManipulator.java
private BufferedImage manipulate(BufferedImage sourceImage) { double aspectRatio = sourceImage.getHeight() / (double) sourceImage.getWidth(); int height = (int) Math.floor(IMAGE_WIDTH * aspectRatio); BufferedImage destinationImage = new BufferedImage(IMAGE_WIDTH, height, BufferedImage.TYPE_INT_RGB); render(sourceImage, destinationImage); return destinationImage; }
From source file:fi.helsinki.opintoni.service.ImageService.java
private BufferedImage toJpg(BufferedImage bufferedImage) { BufferedImage jpgImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_INT_RGB); jpgImage.createGraphics().drawImage(bufferedImage, 0, 0, Color.BLACK, null); return jpgImage; }
From source file:com.gargoylesoftware.htmlunit.javascript.host.canvas.CanvasRenderingContext2D.java
/** * Constructs in association with {@link HTMLCanvasElement}. * @param canvas the {@link HTMLCanvasElement} *///www. ja va 2s. c om public CanvasRenderingContext2D(final HTMLCanvasElement canvas) { canvas_ = canvas; image_ = new BufferedImage(canvas.getWidth(), canvas.getHeight(), BufferedImage.TYPE_INT_RGB); graphics2D_ = image_.createGraphics(); }
From source file:image.writer.ImageWriterExample1.java
/** * Creates a bitmap file. We paint a few things on a bitmap and then save the bitmap using * an ImageWriter./*ww w . ja va 2 s.c om*/ * @param outputFile the target file * @param format the target format (a MIME type, ex. "image/png") * @throws IOException In case of an I/O error */ public void generateBitmapUsingJava2D(File outputFile, String format) throws IOException { //String compression = "CCITT T.6"; String compression = "PackBits"; boolean monochrome = compression.startsWith("CCITT"); //CCITT is for 1bit b/w only BufferedImage bimg; if (monochrome) { bimg = new BufferedImage(400, 200, BufferedImage.TYPE_BYTE_BINARY); } else { bimg = new BufferedImage(400, 200, BufferedImage.TYPE_INT_RGB); } Graphics2D g2d = bimg.createGraphics(); g2d.setBackground(Color.white); g2d.clearRect(0, 0, 400, 200); g2d.setColor(Color.black); //Paint something paintSome(g2d, 1); OutputStream out = new java.io.FileOutputStream(outputFile); out = new java.io.BufferedOutputStream(out); try { ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor(format); ImageWriterParams params = new ImageWriterParams(); params.setCompressionMethod(compression); params.setResolution(72); writer.writeImage(bimg, out, params); } finally { IOUtils.closeQuietly(out); } }
From source file:fungus.JungVisualizer.java
public void saveAsPNG() { String filePath = String.format("%s/%s-%03d.png", imageDir, nameFragment, CDState.getCycle()); File dir = new File(imageDir); dir.mkdir();/*from ww w . j a v a2s. c o m*/ Dimension size = visualizer.getSize(); BufferedImage image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); visualizer.paint(g2); try { File file = new File(filePath); ImageIO.write(image, "png", file); } catch (Exception e) { System.out.println(e); } }
From source file:de.mpg.imeji.logic.storage.util.ImageUtils.java
/** * Scale a {@link BufferedImage} to new size. Is faster than the basic {@link ImageUtils}.scaleImage method, has the * same quality. If it is a thumbnail, cut the images to fit into the raster * /*from w ww. j ava2 s . co m*/ * @param image original image * @param size the size to be resized to * @param resolution the type of the image. Might be thumb or web * @return the resized images * @throws Exception */ public static BufferedImage scaleImageFast(BufferedImage image, int size, FileResolution resolution) throws Exception { int width = image.getWidth(null); int height = image.getHeight(null); BufferedImage newImg = null; Image rescaledImage; if (width > height) { if (FileResolution.THUMBNAIL.equals(resolution)) { newImg = new BufferedImage(height, height, BufferedImage.TYPE_INT_RGB); Graphics g1 = newImg.createGraphics(); g1.drawImage(image, (height - width) / 2, 0, null); if (height > size) rescaledImage = getScaledInstance(newImg, size, size, RenderingHints.VALUE_INTERPOLATION_BILINEAR, RESCALE_HIGH_QUALITY); else rescaledImage = newImg; } else rescaledImage = getScaledInstance(image, size, height * size / width, RenderingHints.VALUE_INTERPOLATION_BILINEAR, RESCALE_HIGH_QUALITY); } else { if (FileResolution.THUMBNAIL.equals(resolution)) { newImg = new BufferedImage(width, width, BufferedImage.TYPE_INT_RGB); Graphics g1 = newImg.createGraphics(); g1.drawImage(image, 0, (width - height) / 2, null); if (width > size) rescaledImage = getScaledInstance(newImg, size, size, RenderingHints.VALUE_INTERPOLATION_BILINEAR, RESCALE_HIGH_QUALITY); else rescaledImage = newImg; } else rescaledImage = getScaledInstance(image, width * size / height, size, RenderingHints.VALUE_INTERPOLATION_BILINEAR, RESCALE_HIGH_QUALITY); } BufferedImage rescaledBufferedImage = new BufferedImage(rescaledImage.getWidth(null), rescaledImage.getHeight(null), BufferedImage.TYPE_INT_RGB); Graphics g2 = rescaledBufferedImage.getGraphics(); g2.drawImage(rescaledImage, 0, 0, null); return rescaledBufferedImage; }
From source file:ConvolveApp.java
public void createBufferedImages() { biSrc = new BufferedImage(displayImage.getWidth(this), displayImage.getHeight(this), BufferedImage.TYPE_INT_RGB); big = biSrc.createGraphics();//from ww w .j a va 2 s. c om big.drawImage(displayImage, 0, 0, this); biDest = new BufferedImage(displayImage.getWidth(this), displayImage.getHeight(this), BufferedImage.TYPE_INT_RGB); }
From source file:Myopia.java
@Override public void paint(Graphics g, JComponent c) { int w = c.getWidth(); int h = c.getHeight(); if (w == 0 || h == 0) { return;/* w ww .j av a2 s.co m*/ } // Only create the offscreen image if the one we have // is the wrong size. if (mOffscreenImage == null || mOffscreenImage.getWidth() != w || mOffscreenImage.getHeight() != h) { mOffscreenImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); } Graphics2D ig2 = mOffscreenImage.createGraphics(); ig2.setClip(g.getClip()); super.paint(ig2, c); ig2.dispose(); Graphics2D g2 = (Graphics2D) g; g2.drawImage(mOffscreenImage, mOperation, 0, 0); }