Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Imagero & getAsBufferedImage problem



Just starting to dig into Imagero. I pulled down a demo app from the following site and the compiler barfs at the getAsBufferedImage with the following message.

getAsBufferedImage(com.imagero.reader.ImageProcOptions) in com.imagero.reader.Imagero cannot be applied to (com.imagero.reader.ImageReader,int,boolean)
img



Full code here. Help?


import com.imagero.reader.ImageReader; import com.imagero.reader.MetadataUtils; import com.imagero.reader.ReaderFactory;

import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;


/** * @author Andrey Kuznetsov */

public class SimpleImagePanel extends JPanel {

	private static final long serialVersionUID = 7526471155622776147L;
	Image img;
    String name;

public SimpleImagePanel(File file) throws IOException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
ImageReader reader = ReaderFactory.createReader(file);
name = file.getName();
img = MetadataUtils.getAsBufferedImage(reader, 0, true);
}


    public void paint(Graphics g) {
        Dimension d = getPreferredSize();
        int width = d.width;
        int height = d.height;
        Graphics g2 = g.create(0, 0, width, height);
        //fill background
        int w = 10;
        int h = 10;
        int r = 0;
        int c = 0;

        for (int j = 0; j < height; j += h) {
            c = 0;
            r++;
            for (int i = 0; i < width; i += w) {
                c++;
                if (((r & 1) ^ (c & 1)) == 0) {
                    g2.setColor(Color.white);
                }
                else {
                    g2.setColor(Color.lightGray);
                }
                g2.fillRect(i, j, w, h);
            }
        }
        //draw image
        if (img != null) {
            g2.drawImage(img, 0, 0, this);
        }
        g2.dispose();
    }

public Dimension getPreferredSize() {
if (img != null) {
return new Dimension(img.getWidth(null), img.getHeight (null));
}
return super.getPreferredSize();
}


public static void main(String[] args) throws IOException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
File file = new File(args[0]);


        SimpleImagePanel t = new SimpleImagePanel(file);
        ScrollPane sp = new ScrollPane();
        sp.add(t);
        JFrame frame = new JFrame(t.name);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(sp);
        frame.pack();
        frame.setVisible(true);
    }
}


-- Kevin Muldoon, Owner TrueBlueDot - Fine Art Printing New Haven, CT 06511 email@hidden www.truebluedot.com "Our pigment meets your imagination"



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.