Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            image_list = new System.Collections.Generic.List<Image>();
               delay_list = new List<int>();

            for (int i = 0; i < names.Length; i++)
            {
                GifDecoder myDecoder = new GifDecoder(names[i]);
                myDecoder.Decode();

                for (int j = 0; j < myDecoder.Frames.Count; j++)
                {
                    image_list.Add(myDecoder.Frames[j].TheImage);
                    delay_list.Add(myDecoder.Frames[j].Delay);
                }
            }

            List<byte> mainad = new System.Collections.Generic.List<byte>();
            string map_str = "";

            for (int i = 0; i < image_list.Count ; i++)
            {
                MemoryStream ms = new MemoryStream();
                image_list[i].Save(ms, System.Drawing.Imaging.ImageFormat.Png);

                byte[] all = ms.ToArray();

                for (int j = 0; j < all.Length; j++)
                {
                    mainad.Add(all[j]);
                }

                if (i != image_list.Count - 1)
                    map_str += all.Length + "|" + delay_list[i] + ",";
                else
                    map_str += all.Length + "|" + delay_list[i];

            }

            string cx = EnCryptDecrypt.CryptorEngine.Encrypt(map_str, false);
            byte[] mapfile = Encoding.UTF8.GetBytes(cx);

            int map_len = mapfile.Length;

            byte[] big_file = new byte[map_len + mainad.Count + 4];

            big_file[0] = (byte)((map_len >> 24) & 0xFF);
            big_file[1] = (byte)((map_len >> 16) & 0xFF);
            big_file[2] = (byte)((map_len >> 8) & 0xFF);
            big_file[3] = (byte)(map_len & 0xFF);

            int index = 4;

            for (int i = 0; i < mapfile.Length; i++)
            {
                big_file[index] = mapfile[i];
                index++;
            }

            for (int i = 0; i < mainad.Count ; i++)
            {
                big_file[index] = mainad[i];
                index++;
            }

            //==============
            //we have map , dely and images !
            FileStream fs3 = new FileStream(Environment.CurrentDirectory + "\\export\\mainadx.big", FileMode.Create);
            fs3.Write(big_file, 0, big_file.Length);
            fs3.Close();

            t = new Thread(new ThreadStart(new_thread));
            t.Start();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Call this method from the event handler. Starts the LoadGif method
 /// off on a background thread.
 /// </summary>
 private void DoLoadGif()
 {
     DialogResult result = openFileDialog1.ShowDialog();
     if( result == DialogResult.OK )
     {
         // Point at the first frame to avoid IndexOutOfRangeException
         // whilst loading the GIF.
         _imageIndex = 0;
         _decoder = new GifDecoder( openFileDialog1.FileName,
                                    createDebugXMLToolStripMenuItem.Checked );
         StartBackgroundProcess( _decoder, LoadGif, "Decoding..." );
     }
 }