All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ctreber.acearth.gui.PixelCanvas Maven / Gradle / Ivy

Go to download

PlantUML is a component that allows to quickly write : * sequence diagram, * use case diagram, * class diagram, * activity diagram, * component diagram, * state diagram * object diagram

The newest version!
package com.ctreber.acearth.gui;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

import javax.imageio.ImageIO;

import com.ctreber.acearth.renderer.RenderTarget;

/**
 * 

* Swing compatible drawing surface for images and graphics. * *

* © 2002 Christian Treber, [email protected] * * @author Christian Treber, [email protected] * */ public class PixelCanvas implements RenderTarget { final private int fImageWidth; final private int fImageHeight; final private BufferedImage fEarthImage2; /** *

* Construct a canvas of the specified size. * * @param pWidth * Width * @param pHeight * Height */ public PixelCanvas(int pWidth, int pHeight) { fImageWidth = pWidth; fImageHeight = pHeight; fEarthImage2 = new BufferedImage(fImageWidth, fImageHeight, BufferedImage.TYPE_INT_RGB); } public Graphics2D getGraphics2D() { return fEarthImage2.createGraphics(); } public void setPixel(int pX, int pY, int pA, int pR, int pG, int pB) { setPixel(pX, pY, new Color(pR, pG, pB, pA)); } public void setPixel(int pX, int pY, Color pColor) { fEarthImage2.setRGB(pX, pY, pColor.getRGB()); } public int getImageWidth() { return fImageWidth; } public int getImageHeight() { return fImageHeight; } public boolean saveToImage(String pFileName, String pFormat) throws IOException { return ImageIO.write(fEarthImage2, pFormat, new File(pFileName)); } public void saveToImage(OutputStream os) throws IOException { ImageIO.write(fEarthImage2, "png", os); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy