예제 #1
0
    public void Save(string path)
    {
        int n_pixel = ((originalData.Length / 8) / 4);
        int side    = CalcSide(n_pixel);

        var bmp   = new Bitmap(side, side);
        var bytes = originalData.ToByteArray();

        int index = 0;

        for (int i = 0; i < bmp.Width; i++)
        {
            for (int j = 0; j < bmp.Height; j++)
            {
                int a = index < bytes.Length ? bytes[index] : 255;
                index++;
                int r = index < bytes.Length ? bytes[index] : 255;
                index++;
                int g = index < bytes.Length ? bytes[index] : 255;
                index++;
                int b = index < bytes.Length ? bytes[index] : 255;
                index++;

                bmp.SetPixel(i, j, Color.FromArgb(a, r, g, b));
            }
        }


        // 保存する
        bmp.Save(path, System.Drawing.Imaging.ImageFormat.Png);
    }
예제 #2
0
    public void Load(ZipData zip)
    {
        var code = new BoolList();
        var info = new InfoSource();

        this.path = zip.path;

        for (int i = 0; i < zip.data.Length; i++)
        {
            code.Add(zip.data[i]);

            if (zip.Codes.ContainsKey(code))
            {
                // 一部分複合する.瞬時符号って最高
                info.AddRange(zip.Codes[code]);

                code.Clear();
            }
        }

        this.byteArray = new byte[zip.byteNumber];
        var temp = info.ToByteArray();

        for (int i = 0; i < this.byteArray.Length; i++)
        {
            byteArray[i] = temp[i];
        }

        /*
         * for(int i = 0 ; i < byteArray.Length ; i++ )
         * {
         *  byte b = 0x00;
         *  for(int j = 0 ; j < 8 ; j++ ){
         *      b <<= 1;
         *      b |= info[ i * 8 + j ] ? (byte)0x01 : (byte)0x00;
         *  }
         *  byteArray[i] = b;
         * }*/
    }