Examples of DAByteArrayOutputStream


Examples of org.apache.flex.utils.DAByteArrayOutputStream

        float q = 1.0f;
        if (quality != null)
            q = quality.floatValue();
        writeParam.setCompressionQuality(q);

        DAByteArrayOutputStream buffer = new DAByteArrayOutputStream();
        writer.setOutput(new MemoryCacheImageOutputStream(buffer));

        IIOImage ioImage = new IIOImage(bufferedImage, null, null);

        writer.write(null, ioImage, writeParam);
        writer.dispose();

        return buffer.getDirectByteArray();
    }
View Full Code Here

Examples of org.apache.flex.utils.DAByteArrayOutputStream

    }

    public static byte[] deflate(byte[] buf) throws IOException
    {
        Deflater deflater = new Deflater(Deflater.BEST_SPEED);
        DAByteArrayOutputStream out = new DAByteArrayOutputStream();
        DeflaterOutputStream deflaterStream = new DeflaterOutputStream(out, deflater);
        try
        {
            deflaterStream.write(buf, 0, buf.length);
            deflaterStream.finish();
            deflater.end();
        }
        finally
        {
            IOUtils.closeQuietly(deflaterStream);
        }
        return out.getDirectByteArray();
    }
View Full Code Here

Examples of org.apache.flex.utils.DAByteArrayOutputStream

        if (!decoder.SetDecoderProperties(properties))
            throw new IOException("Incorrect stream properties");

        /* swf omits the len field */

        DAByteArrayOutputStream os = new DAByteArrayOutputStream();

        long outSize = -1;
        if (!decoder.Code(inputStream, os, outSize))
            throw new IOException("Error in data stream");

        os.flush();
        readIndex = 0;
        buffer = os.getDirectByteArray();
    }
View Full Code Here

Examples of org.apache.flex.utils.DAByteArrayOutputStream

     * methods.
     */
    public void compress(IOutputBitStream outputBitStream) throws IOException
    {
        assert byteArrayOutputStream == null;
        byteArrayOutputStream = new DAByteArrayOutputStream();
        StreamAdapter is = new StreamAdapter(outputBitStream);
        encoder.Code(is, byteArrayOutputStream, -1, -1, null);
    }
View Full Code Here

Examples of org.apache.flex.utils.DAByteArrayOutputStream

    {
        byte[] contents = null;
       
        try
        {
            final DAByteArrayOutputStream buffer = new DAByteArrayOutputStream();
            final InputStream fileInputStream = fileSpec.createInputStream();
            IOUtils.copy(fileInputStream, buffer);
            IOUtils.closeQuietly(buffer);
            IOUtils.closeQuietly(fileInputStream);
            contents = buffer.getDirectByteArray();
        }
        catch (IOException e)
        {
        }
       
View Full Code Here

Examples of org.apache.flex.utils.DAByteArrayOutputStream

     * @param useCompression true if the output stream is compressed.
     */
    public OutputBitStream(boolean useCompression)
    {
        this.useCompression = useCompression;
        flatOutputBuffer = new DAByteArrayOutputStream();
        if (useCompression)
        {
            filteredOutput = new DeflaterOutputStream(flatOutputBuffer);
        }
        else
View Full Code Here

Examples of org.apache.flex.utils.DAByteArrayOutputStream

    }

    @Override
    public String readString()
    {
        final DAByteArrayOutputStream buffer = new DAByteArrayOutputStream();
        for (int nextByte = readUI8(); nextByte != 0; nextByte = readUI8())
        {
            buffer.write(nextByte);
        }

        try
        {
            return new String(buffer.getDirectByteArray(), 0, buffer.size(), "UTF-8");
        }
        catch (UnsupportedEncodingException e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here

Examples of org.apache.flex.utils.DAByteArrayOutputStream

    }

    private byte[] readFully(InputStream inputStream)
    {
        BufferedInputStream in = new BufferedInputStream(inputStream);
        DAByteArrayOutputStream baos = new DAByteArrayOutputStream();

        // write 2 bytes - number of frames to skip...
        baos.write(0);
        baos.write(0);

        // look for the first 11-bit frame sync. skip everything before the frame sync
        int b, state = 0;

        // 3-state FSM
        try
        {
            while ((b = in.read()) != -1)
            {
                if (state == 0)
                {
                    if (b == 255)
                    {
                        state = 1;
                    }
                }
                else if (state == 1)
                {
                    if ((b >> 5 & 0x7) == 7)
                    {
                        baos.write(255);
                        baos.write(b);
                        state = 2;
                    }
                    else
                    {
                        state = 0;
                    }
                }
                else if (state == 2)
                {
                    baos.write(b);
                }
                else
                {
                    // assert false;
                }
            }
            return baos.getDirectByteArray();
        }
        catch (IOException e)
        {
        }
        finally
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.