Examples of PngImage


Examples of com.googlecode.pngtastic.core.PngImage

   
     public void compressPNG(String inputFilePath, String outputFilePath, String fileType) {
             try
      {
       PngOptimizer optimizer = new PngOptimizer();
        PngImage image = new PngImage(inputFilePath);
        optimizer.optimize(image, outputFilePath, false,9);
      }catch (IOException e)
      {
        e.printStackTrace();
      }       
View Full Code Here

Examples of com.sixlegs.image.png.PngImage

public class PixelGrabberExample
{
    static public void main(String[] args)
    throws IOException
    {
        PngImage png = new PngImage(args[0]);

        int x = Integer.parseInt(args[1]);
        int y = Integer.parseInt(args[2]);
        int w = png.getWidth();

        int[] pixels = new int[1];
        PixelGrabber pg =
          new PixelGrabber(png, x, y, 1, 1, pixels, 0, w);
        try {
View Full Code Here

Examples of com.sixlegs.image.png.PngImage

    {
        String loc = getParameter("URL");
        try {
            if (loc != null) {
                URL url = new URL(getCodeBase(), loc);
                png = new PngImage(url);
                String bgparam = getParameter("bgcolor");
                if (bgparam != null)
                    imgbg = new Color(Integer.valueOf(bgparam, 16).intValue());
                if (imgbg == null)
                    imgbg = png.getBackgroundColor();
View Full Code Here

Examples of com.sixlegs.image.png.PngImage

    {
        // Register instance of this class as "heLo" handler
        PngImage.registerChunk(new ChunkHandlerExample(), "heLo");

        // Read PNG image from file
        PngImage png = new PngImage(args[0]);

        // Ensures that entire PNG image has been read,
        // triggering handleChunk when a "heLo" chunk is found
        png.getEverything();
    }
View Full Code Here

Examples of com.sixlegs.image.png.PngImage

    {
        // Update ImageObservers after each interlace pass
        PngImage.setProgressiveDisplay(true);

            // Read PNG image from file
        PngImage png = new PngImage(args[0]);
        Toolkit tk = Toolkit.getDefaultToolkit();
        Image img = tk.createImage(png);
        int w = png.getWidth();
        int h = png.getHeight();

        // Call prepareImage using an instance of this class
        // as the ImageObserver; triggers imageUpdate (below)
        tk.prepareImage(img, w, h, new ObserverExample());
    }
View Full Code Here

Examples of com.sixlegs.image.png.PngImage

        try {
            // Makes errors in ancillary chunks fatal
            PngImage.setAllErrorsFatal(true);

            // Read PNG image from file
            PngImage png = new PngImage(args[0]);

            // Read entire PNG image (doesn't throw exceptions)
            png.getEverything();

            // Print all errors
            if (png.hasErrors()) {
                System.err.println("Errors in PNG processing:");
                for (Enumeration e = png.getErrors(); e.hasMoreElements();) {
                    // Objects returned by getErrors derive from IOException,
                    // but you usually only want to print them
                    System.err.println("  " + e.nextElement());
                }
            }
View Full Code Here

Examples of com.sixlegs.image.png.PngImage

{
    public static void main(String[] args)
    throws IOException
    {
        // Read PNG image from file
        PngImage png = new PngImage(args[0]);

        // Ensures that entire PNG image has been read
        png.getEverything();

        // Print all available properties
        for (Enumeration e = png.getProperties(); e.hasMoreElements();) {
            String key = (String)e.nextElement();
            System.out.println(key);
            System.out.println("\t" + png.getProperty(key));
        }
    }
View Full Code Here

Examples of com.sixlegs.png.PngImage

        imagePanel = new ImagePanel();
        Dimension size = new Dimension(400, 300);
        File file = (args.length > 0) ? new File(args[0]) : null;
        if (file != null) {
            try {
                PngImage png = readHeader(file);       
                size.setSize(png.getWidth(), png.getHeight());
            } catch (IOException e) {
                // ignore here, open will re-throw
            }
        }
        imagePanel.setStretchMode(ImagePanel.STRETCH_PRESERVE);
View Full Code Here

Examples of com.sixlegs.png.PngImage

    }

    private static PngImage readHeader(File file)
    throws IOException
    {
        PngImage png = new PngImage(new PngConfig.Builder().readLimit(PngConfig.READ_HEADER).build());
        png.read(file);
        return png;
    }
View Full Code Here

Examples of com.sixlegs.png.PngImage

    }

    private BufferedImage readPngResource(String path)
    {
        try {
            return new PngImage().read(getClass().getResourceAsStream(path), true);
        } catch (IOException e) {
            throw new Error(e.getMessage());
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.