List of usage examples for java.awt.image BufferedImage TYPE_INT_ARGB
int TYPE_INT_ARGB
To view the source code for java.awt.image BufferedImage TYPE_INT_ARGB.
Click Source Link
From source file:web.diva.server.model.profileplot.ProfilePlotImgeGenerator.java
public String toImage() { image = new BufferedImage(900, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = image.createGraphics(); graphics.setPaint(Color.WHITE); super.forceFullRepaint(graphics); // super.paint(graphics); byte[] imageData = null; try {/*from www. j a v a 2 s . c o m*/ imageData = in.encode(image); } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } String base64 = Base64.encodeBytes(imageData); base64 = "data:image/png;base64," + base64; return base64; }
From source file:bachelorthesis.captchabuilder.builder.CaptchaBuilder.java
/** * Constructor/* ww w . ja v a 2 s. com*/ * * @param width the width of the captcha to be created * @param height the width of the captcha to be created * @param buildSequence string arguments to create the captcha * <p/> * @throws ParseException */ public CaptchaBuilder(int width, int height, String buildSequence) throws ParseException { this.builders = new ArrayDeque<>(); this.setBuildSequence(buildSequence); img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); answer = ""; }
From source file:org.jfree.data.general.HeatMapUtilities.java
/** * Creates an image that displays the values from the specified dataset. * * @param dataset the dataset (<code>null</code> not permitted). * @param paintScale the paint scale for the z-values (<code>null</code> * not permitted)./* ww w.j a v a 2 s.c o m*/ * * @return A buffered image. */ public static BufferedImage createHeatMapImage(HeatMapDataset dataset, PaintScale paintScale) { ParamChecks.nullNotPermitted(dataset, "dataset"); ParamChecks.nullNotPermitted(paintScale, "paintScale"); int xCount = dataset.getXSampleCount(); int yCount = dataset.getYSampleCount(); BufferedImage image = new BufferedImage(xCount, yCount, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); for (int xIndex = 0; xIndex < xCount; xIndex++) { for (int yIndex = 0; yIndex < yCount; yIndex++) { double z = dataset.getZValue(xIndex, yIndex); Paint p = paintScale.getPaint(z); g2.setPaint(p); g2.fillRect(xIndex, yCount - yIndex - 1, 1, 1); } } return image; }
From source file:com.igormaznitsa.sciareto.ui.UiUtils.java
@Nonnull public static Image makeBadgedRightBottom(@Nonnull final Image base, @Nonnull final Image badge) { final int width = Math.max(base.getWidth(null), badge.getWidth(null)); final int height = Math.max(base.getHeight(null), badge.getHeight(null)); final BufferedImage result = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); final Graphics gfx = result.getGraphics(); try {/* w w w .j ava 2 s. c om*/ gfx.drawImage(base, (width - base.getWidth(null)) / 2, (height - base.getHeight(null)) / 2, null); gfx.drawImage(badge, width - badge.getWidth(null) - 1, height - badge.getHeight(null) - 1, null); } finally { gfx.dispose(); } return result; }
From source file:com.compomics.pepshell.view.statistics.CleavingProbabilityPane.java
@Override public void setGraphData(PepshellProtein aPepshellProtein) { //obligatory checks if (aPepshellProtein != null && experiment.getProteins().contains(aPepshellProtein)) { if (aPepshellProtein != currentPepshellProtein) { //TODO: run this outside of the gui thread currentPepshellProtein = experiment.getProteins() .get(experiment.getProteins().indexOf(aPepshellProtein)); XYSeriesCollection xYSeriesCollection = new XYSeriesCollection(); fillSeries(currentPepshellProtein).forEach(xYSeriesCollection::addSeries); JFreeChart CPDTchart = ChartFactory.createXYLineChart("probability of cleaving", "aminoacids of " + currentPepshellProtein.getVisibleAccession(), "probability", xYSeriesCollection, PlotOrientation.VERTICAL, false, true, false); prettifyChart(CPDTchart);/*from www . j a va 2 s . c o m*/ CPDTchart.getXYPlot().getRangeAxis().setLowerBound(cutoff - 0.05); for (int i = 0; i < CPDTchart.getXYPlot().getSeriesCount(); i++) { CPDTchart.getXYPlot().getRenderer().setSeriesStroke(i, new BasicStroke(5)); } if (!aPepshellProtein.getDomains().isEmpty()) { CPDTchart.setBackgroundImageAlpha(0.18f); CPDTchart.getXYPlot().getDomainAxis().setRange(0, aPepshellProtein.getProteinSequence().length()); BufferedImage anImage = new BufferedImage(this.getHeight(), this.getWidth(), BufferedImage.TYPE_INT_ARGB); for (FeatureWithLocation aDomain : aPepshellProtein.getDomains()) { anImage.getGraphics().drawRect(aDomain.getStartPosition(), 0, aDomain.getEndPosition(), this.getHeight()); } CPDTchart.setBackgroundImage(anImage); } chart.setChart(CPDTchart); } } else { chart.setChart(null); this.getGraphics().drawString("missing data", 0, 0); } }
From source file:com.uwsoft.editor.proxy.ResolutionManager.java
public static BufferedImage imageResize(File file, float ratio) { BufferedImage destinationBufferedImage = null; try {/* w ww . j a va 2 s . c om*/ BufferedImage sourceBufferedImage = ImageIO.read(file); if (ratio == 1.0) { return sourceBufferedImage; } // When image has to be resized smaller then 3 pixels we should leave it as is, as to ResampleOP limitations // But it should also trigger a warning dialog at the and of the import, to notify the user of non resized images. if (sourceBufferedImage.getWidth() * ratio < 3 || sourceBufferedImage.getHeight() * ratio < 3) { return null; } int newWidth = Math.max(3, Math.round(sourceBufferedImage.getWidth() * ratio)); int newHeight = Math.max(3, Math.round(sourceBufferedImage.getHeight() * ratio)); String name = file.getName(); Integer[] patches = null; if (name.endsWith(EXTENSION_9PATCH)) { patches = NinePatchUtils.findPatches(sourceBufferedImage); sourceBufferedImage = NinePatchUtils.removePatches(sourceBufferedImage); newWidth = Math.round(sourceBufferedImage.getWidth() * ratio); newHeight = Math.round(sourceBufferedImage.getHeight() * ratio); System.out.println(sourceBufferedImage.getWidth()); destinationBufferedImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = destinationBufferedImage.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); g2.drawImage(sourceBufferedImage, 0, 0, newWidth, newHeight, null); g2.dispose(); } else { // resize with bilinear filter ResampleOp resampleOp = new ResampleOp(newWidth, newHeight); destinationBufferedImage = resampleOp.filter(sourceBufferedImage, null); } if (patches != null) { destinationBufferedImage = NinePatchUtils.convertTo9Patch(destinationBufferedImage, patches, ratio); } } catch (IOException ignored) { } return destinationBufferedImage; }
From source file:de.darkblue.bongloader2.utils.ToolBox.java
public static BufferedImage resizeImage(BufferedImage image, int width, int height) { BufferedImage returnValue = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g2D = returnValue.createGraphics(); g2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); AffineTransform at = AffineTransform.getScaleInstance((double) width / image.getWidth(), (double) height / image.getHeight()); g2D.drawRenderedImage(image, at);/*from ww w . j av a 2s . c o m*/ return returnValue; }
From source file:peakml.graphics.JFreeChartTools.java
/** * This method writes the given graph to the output stream in the PNG format. * /*from w w w.j a va 2 s . co m*/ * @param out The output stream to write to. * @param chart The chart to be written. * @param width The width of the image. * @param height The height of the image. * @throws IOException Thrown when an error occurs with the IO. */ public static void writeAsPNG(OutputStream out, JFreeChart chart, int width, int height) throws IOException { BufferedImage graph_img = new BufferedImage(800, 500, BufferedImage.TYPE_INT_ARGB); chart.draw(graph_img.createGraphics(), new java.awt.Rectangle(0, 0, 800, 500)); javax.imageio.ImageIO.write(graph_img, "png", out); }
From source file:org.apache.fop.visual.BitmapComparator.java
/** * Builds a combined image that places a number of images next to each other for * manual, visual comparison./* w ww. j a va 2s . c o m*/ * @param images the array of bitmaps * @return the combined image */ public static BufferedImage buildCompareImage(BufferedImage[] images) { BufferedImage cmp = new BufferedImage(images[0].getWidth() * images.length, images[0].getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = cmp.createGraphics(); g.setPaint(Color.white); g.fillRect(0, 0, cmp.getWidth(), cmp.getHeight()); int lastWidth = 0; for (int i = 0; i < images.length; i++) { if (lastWidth > 0) { g.translate(lastWidth, 0); } if (images[i] != null) { g.drawImage(images[i], 0, 0, null); lastWidth = images[i].getWidth(); } else { lastWidth = 20; //Maybe add a special placeholder image instead later } } g.dispose(); return cmp; }
From source file:D20140128.ApacheXMLGraphicsTest.TilingPatternExample.java
private void generatePNGusingJava2D(File outputFile) throws IOException { BufferedImage image = new BufferedImage(400, 200, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = image.createGraphics(); paintTileAlone(g2d);//from w w w .j a v a 2s . c om paintShapes(g2d); paintText(g2d); g2d.dispose(); ImageWriterUtil.saveAsPNG(image, outputFile); }