Package com.drew.lang

Examples of com.drew.lang.ByteArrayReader


    }

    private static int getInt32FromString(@NotNull String string) throws IOException
    {
        byte[] bytes = string.getBytes();
        return new ByteArrayReader(bytes).getInt32(0);
    }
View Full Code Here


    @Nullable
    public String getJpegQualityString()
    {
        try {
            byte[] b = _directory.getByteArray(PhotoshopDirectory.TAG_JPEG_QUALITY);
            RandomAccessReader 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_PIXEL_ASPECT_RATIO);
            if (bytes == null)
                return null;
            RandomAccessReader 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_PRINT_SCALE);
            if (bytes == null)
                return null;
            RandomAccessReader 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_RESOLUTION_INFO);
            if (bytes == null)
                return null;
            RandomAccessReader 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

    {
        // skip the first 14 bytes
        byte[] iccProfileBytes = new byte[segmentBytes.length - 14];
        System.arraycopy(segmentBytes, 14, iccProfileBytes, 0, segmentBytes.length - 14);

        extract(new ByteArrayReader(iccProfileBytes), metadata);
    }
View Full Code Here

    {
        try {
            final byte[] bytes = _directory.getByteArray(PhotoshopDirectory.TAG_VERSION);
            if (bytes == null)
                return null;
            RandomAccessReader 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 (IOException e) {
            return null;
        }
    }
View Full Code Here

    {
        try {
            final byte bytes[] = _directory.getByteArray(PhotoshopDirectory.TAG_SLICES);
            if (bytes == null)
                return null;
            RandomAccessReader 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;
            RandomAccessReader 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

        return segmentBytes.length > 3 && "JFIF".equals(new String(segmentBytes, 0, 4));
    }

    public void extract(@NotNull byte[] segmentBytes, @NotNull Metadata metadata, @NotNull JpegSegmentType segmentType)
    {
        extract(new ByteArrayReader(segmentBytes), metadata);
    }
View Full Code Here

TOP

Related Classes of com.drew.lang.ByteArrayReader

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.