Exemple #1
0
    private void byteArrayTextConversion(byte[] byteArrayIn)
    {
        System.IO.StreamWriter file  = new System.IO.StreamWriter("C:\\Users\\Flannel\\Desktop\\ImageBytes.txt");   //general byte array in
        System.IO.StreamWriter file2 = new System.IO.StreamWriter("C:\\Users\\Flannel\\Desktop\\ImageBytes2.txt");

        //this is the hexidecimal file
        string hex = ByteArrayToString(byteArrayIn);

        file.Write(hex);
        file.Close();

        //this is the one that we as humans can read
        string hex2 = ByteArrayToStringReadable(byteArrayIn);

        file2.Write(hex2);
        file2.Close();

        int myframeCount = GifHelper.findFrameCount(hex);

        //here we are splitting up the file for our own purposes into each associated block
        Header.Set(hex.Substring(0, Header.bits));
        curGifByteIndex += Header.bits / 2;
        Debug.LogWarning("CUR INDEX: " + curGifByteIndex + "/" + (hex.Length / 2));

        LogicalScreenDescriptor.Set(hex.Substring(Header.bits, LogicalScreenDescriptor.bits));
        curGifByteIndex += LogicalScreenDescriptor.bits / 2;

        LogicalScreenDescriptor.DebugLog();
        Debug.LogWarning("CUR INDEX: " + curGifByteIndex + "/" + (hex.Length / 2));

        GlobalColorTable.Set(hex.Substring(curGifByteIndex * 2, LogicalScreenDescriptor.GlobalColorTableSize * 2));
        curGifByteIndex += LogicalScreenDescriptor.GlobalColorTableSize;

        GlobalColorTable.DebugLog();
        Debug.LogWarning("GLOBAL COLOR TABLE LENGTH: " + LogicalScreenDescriptor.GlobalColorTableSize);
        Debug.LogWarning("CUR INDEX: " + curGifByteIndex + "/" + (hex.Length / 2));

        GraphicsControlExtension.Set(hex.Substring(curGifByteIndex * 2, GraphicsControlExtension.bits));
        curGifByteIndex += GraphicsControlExtension.bits / 2;

        GraphicsControlExtension.DebugLog();
        Debug.LogWarning("CUR INDEX: " + curGifByteIndex + "/" + (hex.Length / 2));

        ApplicationExtensionBlock.Set(hex.Substring(curGifByteIndex * 2, ApplicationExtensionBlock.bits));
        curGifByteIndex += ApplicationExtensionBlock.bits / 2;

        ApplicationExtensionBlock.DebugLog();
        Debug.LogWarning("CUR INDEX: " + curGifByteIndex + "/" + (hex.Length / 2));

        ImageDescriptor.Set(hex.Substring(curGifByteIndex * 2, ImageDescriptor.bits));
        curGifByteIndex += ImageDescriptor.bits / 2;

        ImageDescriptor.DebugLog();
        Debug.LogWarning("CUR INDEX: " + curGifByteIndex + "/" + (hex.Length / 2));


        //Now that we have everything setup we are on to the drawing data
        int ImageDataLength = findLengthOfImageData(hex.Substring(curGifByteIndex * 2));

        ImageData.Set(hex.Substring(curGifByteIndex * 2, ImageDataLength));
        ImageData.bits   = ImageDataLength;
        curGifByteIndex += ImageData.bits / 2;
        Debug.LogWarning("CUR INDEX: " + curGifByteIndex + "/" + (hex.Length / 2));
    }