unsupported image format

lestatt
2013-03-25
2013-03-25
  • lestatt

    lestatt - 2013-03-25

    Hi, i'm not working on an android application, but i thought that this could be the right place anyway, since i'm using java.

    I'm trying to use zbar via JNI for a server batch application: i've to scan barcode from some pdf files.
    I'm trying but all i can get is

    Exception in thread "main" java.lang.UnsupportedOperationException: unsupported image format
    at net.sourceforge.zbar.ImageScanner.scanImage(Native Method)

    Iìll paste an extract of my code:

    first thing i use PDFBOX to convert pdf pages to png files.

        List mylist = new ArrayList<BufferedImage>();
        PDDocument document = PDDocument.load(file);
        List<PDPage> pages = document.getDocumentCatalog().getAllPages();
        for (int i = 0; i < pages.size(); i++) {
            PDPage pDPage = pages.get(i);
            mylist.add(pDPage.convertToImage(BufferedImage.TYPE_BYTE_GRAY,
                    300));
            // mylist.add(pDPage.convertToImage());
        }
        document.close();
    

    than for each element of BufferedImages in mylist i try to use zbar in this way.
    convertBufferedImageToByteArray is a method that reads the buffered image to a byte[]

               Image image = new Image(
                bufferedImage.getWidth(),bufferedImage.getHeight());
    
        try {
    
            image.setData(convertBufferedImageToByteArray(bufferedImage) );
    
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        ImageScanner imageScanner = new ImageScanner();
        imageScanner.scanImage(image);
        SymbolSet results = imageScanner.getResults();
    
        for (Iterator iterator = results.iterator(); iterator.hasNext();) {
            Symbol symbol = (Symbol) iterator.next();
            System.out.println(symbol.getData());
        }
    

    What's wrong with my code?

    TIA
    L.

     
  • lestatt

    lestatt - 2013-03-25

    problem solved

     

Log in to post a comment.