Package com.drew.lang

Examples of com.drew.lang.BufferReader


    {
        byte[] values = _directory.getByteArray(tag);
        if (values == null)
            return null;

        BufferReader reader = new ByteArrayReader(values);

        try
        {
            int val1 = reader.getUInt16(0);
            int val2 = reader.getUInt16(2);

            if (val1 == -1 && val2 == 1)
                return "Slim Low";
            if (val1 == -3 && val2 == 2)
                return "Slim High";
View Full Code Here


    @Nullable
    public String getJpegQualityString()
    {
        try {
            byte[] b = _directory.getByteArray(PhotoshopDirectory.TAG_PHOTOSHOP_JPEG_QUALITY);
            BufferReader reader = new ByteArrayReader(b);
            int q = reader.getUInt16(0); // & 0xFFFF;
            int f = reader.getUInt16(2); // & 0xFFFF;
            int s = reader.getUInt16(4);

            int q1;
            if (q <= 0xFFFF && q >= 0xFFFD)
                q1 = q - 0xFFFC;
            else if (q <= 8)
View Full Code Here

    {
        try {
            byte[] bytes = _directory.getByteArray(PhotoshopDirectory.TAG_PHOTOSHOP_PIXEL_ASPECT_RATIO);
            if (bytes == null)
                return null;
            BufferReader reader = new ByteArrayReader(bytes);
            double d = reader.getDouble64(4);
            return Double.toString(d);
        } catch (Exception e) {
            return null;
        }
    }
View Full Code Here

    {
        try {
            byte bytes[] = _directory.getByteArray(PhotoshopDirectory.TAG_PHOTOSHOP_PRINT_SCALE);
            if (bytes == null)
                return null;
            BufferReader reader = new ByteArrayReader(bytes);
            int style = reader.getInt32(0);
            float locX = reader.getFloat32(2);
            float locY = reader.getFloat32(6);
            float scale = reader.getFloat32(10);
            switch (style) {
                case 0:
                    return "Centered, Scale " + scale;
                case 1:
                    return "Size to fit";
View Full Code Here

    {
        try {
            byte[] bytes = _directory.getByteArray(PhotoshopDirectory.TAG_PHOTOSHOP_RESOLUTION_INFO);
            if (bytes == null)
                return null;
            BufferReader reader = new ByteArrayReader(bytes);
            float resX = reader.getS15Fixed16(0);
            float resY = reader.getS15Fixed16(8); // is this the correct offset? it's only reading 4 bytes each time
            return resX + "x" + resY + " DPI";
        } catch (Exception e) {
            return null;
        }
    }
View Full Code Here

    {
        try {
            final byte[] bytes = _directory.getByteArray(PhotoshopDirectory.TAG_PHOTOSHOP_VERSION);
            if (bytes == null)
                return null;
            BufferReader reader = new ByteArrayReader(bytes);
            int pos = 0;
            int ver = reader.getInt32(0);
            pos += 4;
            pos++;
            int readerLength = reader.getInt32(5);
            pos += 4;
            String readerStr = reader.getString(9, readerLength * 2, "UTF-16");
            pos += readerLength * 2;
            int writerLength = reader.getInt32(pos);
            pos += 4;
            String writerStr = reader.getString(pos, writerLength * 2, "UTF-16");
            pos += writerLength * 2;
            int fileVersion = reader.getInt32(pos);
            return String.format("%d (%s, %s) %d", ver, readerStr, writerStr, fileVersion);
        } catch (BufferBoundsException e) {
            return null;
        }
    }
View Full Code Here

    {
        try {
            final byte bytes[] = _directory.getByteArray(PhotoshopDirectory.TAG_PHOTOSHOP_SLICES);
            if (bytes == null)
                return null;
            BufferReader reader = new ByteArrayReader(bytes);
            int nameLength = reader.getInt32(20);
            String name = reader.getString(24, nameLength * 2, "UTF-16");
            int pos = 24 + nameLength * 2;
            int sliceCount = reader.getInt32(pos);
            //pos += 4;
            return String.format("%s (%d,%d,%d,%d) %d Slices",
                    name, reader.getInt32(4), reader.getInt32(8), reader.getInt32(12), reader.getInt32(16), sliceCount);
            /*for (int i=0;i<sliceCount;i++){
                pos+=16;
                int slNameLen=getInt32(b,pos);
                pos+=4;
                String slName=new String(b, pos, slNameLen*2,"UTF-16");
 
View Full Code Here

    {
        try {
            byte[] v = _directory.getByteArray(tagType);
            if (v == null)
                return null;
            BufferReader reader = new ByteArrayReader(v);
            //int pos = 0;
            int format = reader.getInt32(0);
            //pos += 4;
            int width = reader.getInt32(4);
            //pos += 4;
            int height = reader.getInt32(8);
            //pos += 4;
            //pos += 4; //skip WidthBytes
            int totalSize = reader.getInt32(16);
            //pos += 4;
            int compSize = reader.getInt32(20);
            //pos += 4;
            int bpp = reader.getInt32(24);
            //pos+=2;
            //pos+=2; //skip Number of planes
            //int thumbSize=v.length-pos;
            return String.format("%s, %dx%d, Decomp %d bytes, %d bpp, %d bytes",
                    format == 1 ? "JpegRGB" : "RawRGB",
View Full Code Here

    private String get32BitNumberString(int tag)
    {
        byte[] bytes = _directory.getByteArray(tag);
        if (bytes == null)
            return null;
        BufferReader reader = new ByteArrayReader(bytes);
        try {
            return String.format("%d", reader.getInt32(0));
        } catch (BufferBoundsException e) {
            return null;
        }
    }
View Full Code Here

    @Nullable
    private String getTagDataString(int tagType)
    {
        try {
            byte[] bytes = _directory.getByteArray(tagType);
            BufferReader reader = new ByteArrayReader(bytes);
            int iccTagType = reader.getInt32(0);
            switch (iccTagType) {
                case ICC_TAG_TYPE_TEXT:
                    try {
                        return new String(bytes, 8, bytes.length - 8 - 1, "ASCII");
                    } catch (UnsupportedEncodingException ex) {
                        return new String(bytes, 8, bytes.length - 8 - 1);
                    }
                case ICC_TAG_TYPE_DESC:
                    int stringLength = reader.getInt32(8);
                    return new String(bytes, 12, stringLength - 1);
                case ICC_TAG_TYPE_SIG:
                    return IccReader.getStringFromInt32(reader.getInt32(8));
                case ICC_TAG_TYPE_MEAS: {
                    int observerType = reader.getInt32(8);
                    float x = reader.getS15Fixed16(12);
                    float y = reader.getS15Fixed16(16);
                    float z = reader.getS15Fixed16(20);
                    int geometryType = reader.getInt32(24);
                    float flare = reader.getS15Fixed16(28);
                    int illuminantType = reader.getInt32(32);
                    String observerString;
                    switch (observerType) {
                        case 0:
                            observerString = "Unknown";
                            break;
                        case 1:
                            observerString = "1931 2°";
                            break;
                        case 2:
                            observerString = "1964 10°";
                            break;
                        default:
                            observerString = String.format("Unknown %d", observerType);
                    }
                    String geometryString;
                    switch (geometryType) {
                        case 0:
                            geometryString = "Unknown";
                            break;
                        case 1:
                            geometryString = "0/45 or 45/0";
                            break;
                        case 2:
                            geometryString = "0/d or d/0";
                            break;
                        default:
                            geometryString = String.format("Unknown %d", observerType);
                    }
                    String illuminantString;
                    switch (illuminantType) {
                        case 0:
                            illuminantString = "unknown";
                            break;
                        case 1:
                            illuminantString = "D50";
                            break;
                        case 2:
                            illuminantString = "D65";
                            break;
                        case 3:
                            illuminantString = "D93";
                            break;
                        case 4:
                            illuminantString = "F2";
                            break;
                        case 5:
                            illuminantString = "D55";
                            break;
                        case 6:
                            illuminantString = "A";
                            break;
                        case 7:
                            illuminantString = "Equi-Power (E)";
                            break;
                        case 8:
                            illuminantString = "F8";
                            break;
                        default:
                            illuminantString = String.format("Unknown %d", illuminantType);
                            break;
                    }
                    return String.format("%s Observer, Backing (%s, %s, %s), Geometry %s, Flare %d%%, Illuminant %s",
                            observerString, x, y, z, geometryString, Math.round(flare * 100), illuminantString);
                }
                case ICC_TAG_TYPE_XYZ_ARRAY: {
                    StringBuilder res = new StringBuilder();
                    int count = (bytes.length - 8) / 12;
                    for (int i = 0; i < count; i++) {
                        float x = reader.getS15Fixed16(8 + i * 12);
                        float y = reader.getS15Fixed16(8 + i * 12 + 4);
                        float z = reader.getS15Fixed16(8 + i * 12 + 8);
                        if (i > 0)
                            res.append(", ");
                        res.append("(").append(x).append(", ").append(y).append(", ").append(z).append(")");
                    }
                    return res.toString();
                }
                case ICC_TAG_TYPE_MLUC: {
                    int int1 = reader.getInt32(8);
                    StringBuilder res = new StringBuilder();
                    res.append(int1);
                    //int int2 = reader.getInt32(12);
                    //System.err.format("int1: %d, int2: %d\n", int1, int2);
                    for (int i = 0; i < int1; i++) {
                        String str = IccReader.getStringFromInt32(reader.getInt32(16 + i * 12));
                        int len = reader.getInt32(16 + i * 12 + 4);
                        int ofs = reader.getInt32(16 + i * 12 + 8);
                        String name;
                        try {
                            name = new String(bytes, ofs, len, "UTF-16BE");
                        } catch (UnsupportedEncodingException ex) {
                            name = new String(bytes, ofs, len);
                        }
                        res.append(" ").append(str).append("(").append(name).append(")");
                        //System.err.format("% 3d: %s, len: %d, ofs: %d, \"%s\"\n", i, str, len,ofs,name);
                    }
                    return res.toString();
                }
                case ICC_TAG_TYPE_CURV: {
                    int num = reader.getInt32(8);
                    StringBuilder res = new StringBuilder();
                    for (int i = 0; i < num; i++) {
                        if (i != 0)
                            res.append(", ");
                        res.append(formatDoubleAsString(((float)reader.getUInt16(12 + i * 2)) / 65535.0, 7, false));
                        //res+=String.format("%1.7g",Math.round(((float)iccReader.getInt16(b,12+i*2))/0.065535)/1E7);
                    }
                    return res.toString();
                }
                default:
View Full Code Here

TOP

Related Classes of com.drew.lang.BufferReader

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.