I recently started a small project in which I wanted to use zxing. I downloaded the sources from here. I was able to successfully build the core and the javase jars.
When I tried to code along the sample provided here I ran into a problem I do not quite understand. So far the code looks like this:
public static void main(String[] args)
{
Reader reader = new MultiFormatReader();
ImageIcon imageIcon = new ImageIcon(SOMEPATH);
Image image = imageIcon.getImage();
BufferedImage buffImage = new BufferedImage(
image.getWidth(null),
image.getHeight(null),
BufferedImage.TYPE_INT_RGB);
Graphics2D g = buffImage.createGraphics();
g.drawImage(image, null, null);
LuminanceSource source = new BufferedImageLuminanceSource(buffImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
}
As you can see this is pretty much the same code as presented in the DevelopersNotes. But the code will not compile. The error message is:
Type mismatch: cannot convert from BufferedImageLuminanceSource to LuminanceSource
Does somebody know what I am missing?
Edit:
My imports are currently looking like this:
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.Reader;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;
I added the core.jar as well as the javase.jar to my project. Both I compiled using ant leaving the buildfiles as downloaded.
That’s all correct. You must have some funny business in your imports. Those types are certainly compatible.