Package org.apache.sanselan

Examples of org.apache.sanselan.ImageReadException


            else
                return 0x00000000;
        }
        else if (color.charAt(0) == '%')
        {
            throw new ImageReadException("HSV colors are not implemented " +
                    "even in the XPM specification!");
        }
        else if (color.equals("None"))
            return 0x00000000;
        else
View Full Code Here


        for (int i = 0; i < xpmHeader.numColors; i++)
        {
            row.setLength(0);
            boolean hasMore = parseNextString(cParser, row);
            if (!hasMore)
                throw new ImageReadException("Parsing XPM file failed, " +
                        "file ended while reading palette");
            String name = row.substring(0, xpmHeader.numCharsPerPixel);
            String[] tokens = BasicCParser.tokenizeRow(
                    row.substring(xpmHeader.numCharsPerPixel));
            PaletteEntry paletteEntry = new PaletteEntry();
View Full Code Here

            if (field.tag == tag.tag)
                return field;
        }

        if (failIfMissing)
            throw new ImageReadException("Missing expected field: "
                    + tag.getDescription());

        return null;
    }
View Full Code Here

    {
        String name;
        String token;
        token = cParser.nextToken();
        if (token == null || !token.equals("static"))
            throw new ImageReadException("Parsing XPM file failed, no 'static' token");
        token = cParser.nextToken();
        if (token == null || !token.equals("char"))
            throw new ImageReadException("Parsing XPM file failed, no 'char' token");
        token = cParser.nextToken();
        if (token == null || !token.equals("*"))
            throw new ImageReadException("Parsing XPM file failed, no '*' token");
        name = cParser.nextToken();
        if (name == null)
            throw new ImageReadException("Parsing XPM file failed, no variable name");
        if (name.charAt(0) != '_' && !Character.isLetter(name.charAt(0)))
            throw new ImageReadException("Parsing XPM file failed, variable name " +
                    "doesn't start with letter or underscore");
        for (int i = 0; i < name.length(); i++)
        {
            char c = name.charAt(i);
            if (!Character.isLetterOrDigit(c) && c != '_')
                throw new ImageReadException("Parsing XPM file failed, variable name " +
                        "contains non-letter non-digit non-underscore");
        }
        token = cParser.nextToken();
        if (token == null || !token.equals("["))
            throw new ImageReadException("Parsing XPM file failed, no '[' token");
        token = cParser.nextToken();
        if (token == null || !token.equals("]"))
            throw new ImageReadException("Parsing XPM file failed, no ']' token");
        token = cParser.nextToken();
        if (token == null || !token.equals("="))
            throw new ImageReadException("Parsing XPM file failed, no '=' token");
        token = cParser.nextToken();
        if (token == null || !token.equals("{"))
            throw new ImageReadException("Parsing XPM file failed, no '{' token");

        StringBuilder row = new StringBuilder();
        boolean hasMore = parseNextString(cParser, row);
        if (!hasMore)
            throw new ImageReadException("Parsing XPM file failed, " +
                    "file too short");
        XpmHeader xpmHeader = parseXpmValuesSection(row.toString());
        parsePaletteEntries(xpmHeader, cParser);
        return xpmHeader;
    }
View Full Code Here

    {
        int offsets[] = offsetsField.getIntArrayValue();
        int byteCounts[] = byteCountsField.getIntArrayValue();

        if (offsets.length != byteCounts.length)
            throw new ImageReadException("offsets.length(" + offsets.length
                    + ") != byteCounts.length(" + byteCounts.length + ")");

        ArrayList result = new ArrayList();
        for (int i = 0; i < offsets.length; i++)
        {
View Full Code Here

        else if ((stripOffsets != null) && (stripByteCounts != null))
        {
            return getRawImageDataElements(stripOffsets, stripByteCounts);
        }
        else
            throw new ImageReadException("Couldn't find image data.");
    }
View Full Code Here

        else if ((stripOffsets != null) && (stripByteCounts != null))
            return true;
        else if ((stripOffsets != null) && (stripByteCounts != null))
            return true;
        else
            throw new ImageReadException("Couldn't find image data.");
    }
View Full Code Here

        for (int y = 0; y < xpmHeader.height; y++)
        {
            row.setLength(0);
            hasMore = parseNextString(cParser, row);
            if (y < (xpmHeader.height - 1) && !hasMore)
                throw new ImageReadException("Parsing XPM file failed, " +
                        "insufficient image rows in file");
            int rowOffset = y*xpmHeader.width;
            for (int x = 0; x < xpmHeader.width; x++)
            {
                String index = row.substring(x*xpmHeader.numCharsPerPixel,
                        (x + 1)*xpmHeader.numCharsPerPixel);
                PaletteEntry paletteEntry = (PaletteEntry) xpmHeader.palette.get(index);
                if (paletteEntry == null) {
                    throw new ImageReadException("No palette entry was defined " +
                            "for " + index);
                }
                if (bpp <= 16)
                    dataBuffer.setElem(rowOffset + x, paletteEntry.index);
                else
                    dataBuffer.setElem(rowOffset + x, paletteEntry.getBestARGB());
            }
        }

        while (hasMore)
        {
            row.setLength(0);
            hasMore = parseNextString(cParser, row);
        }
       
        String token = cParser.nextToken();
        if (!token.equals(";"))
            throw new ImageReadException("Last token wasn't ';'");
       
        return image;
    }
View Full Code Here

            int byteCount = jpegInterchangeFormatLength.getIntArrayValue()[0];

            return new ImageDataElement(offset, byteCount);
        }
        else
            throw new ImageReadException("Couldn't find image data.");
    }
View Full Code Here

                    break;
                pageTable.add(new Integer(pageOffset));
            }

            if (id != DcxHeader.DCX_ID)
                throw new ImageReadException("Not a Valid DCX File: file id incorrect");
            if (pageTable.size() == 1024)
                throw new ImageReadException("DCX page table not terminated by zero entry");
           
            Object[] objects = pageTable.toArray();
            int[] pages = new int[objects.length];
            for (int i = 0; i < objects.length; i++)
                pages[i] = ((Integer) objects[i]).intValue();
View Full Code Here

TOP

Related Classes of org.apache.sanselan.ImageReadException

Copyright © 2018 www.massapicom. 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.