Package net.cakenet.jsaton.util

Examples of net.cakenet.jsaton.util.InvalidImageDataException


            if(val != null)
                return val;
            decoded.remove(str);
        }
        if (str.charAt(0) != 'g')
            throw new InvalidImageDataException("Not a gzip compressed image");
        byte[] data = CompressionUtil.inflate(DatatypeConverter.parseBase64Binary(str.substring(1)), true);
        int width = ((data[0] & 0xff) << 8) | (data[1] & 0xff);
        int height = ((data[2] & 0xff) << 8) | (data[3] & 0xff);
        byte[] raw = new byte[data.length - 4];
        System.arraycopy(data, 4, raw, 0, raw.length);
View Full Code Here


            if(val != null)
                return val;
            decoded.remove(src);
        }
        if (src.charAt(0) != 'c')
            throw new InvalidImageDataException("Invalid SCAR string (doesn't start with 'c')");
        SimpleImage img = toImage(CompressionUtil.inflate(DatatypeConverter.parseBase64Binary(src.substring(1)), false), width, height);
        decoded.put(src, new WeakReference<>(img));
        return img;
    }
View Full Code Here

    }

    private static SimpleImage toImage(byte[] source, int width, int height) throws InvalidImageDataException {
        int pl = width * height;
        if (source.length != pl*3)
            throw new InvalidImageDataException("Image data length doesn't match required length. act:" + source.length + " exp: " + (pl * 3));
        int[] pix = new int[pl];
        int off = 0;
        for (int i = 0; i < pix.length; i++) {
            int r = (source[off++] & 0xff), g = (source[off++] & 0xff), b = (source[off++] & 0xff);
            pix[i] = (r << 16) | (g << 8) | b;
View Full Code Here

TOP

Related Classes of net.cakenet.jsaton.util.InvalidImageDataException

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.