示例#1
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog o = new OpenFileDialog();

            o.Multiselect = false;
            o.DefaultExt  = ".png";
            o.Filter      = "All formats (*.png, *.bmp)|*.png;*.bmp|BitMaP (*.bmp)|*.bmp|Portable Network Graphics (*.png)|*.png";
            if (o.ShowDialog() == DialogResult.OK)
            {
                Bitmap bmp = new Bitmap(o.FileName);

                Color[] palette = (this.info.imgs > 1) ? this.info.paleta.colores : null;
                palette = this.info.paleta.colores;
                int selIndex = GetSelectedIndex();
                if (info.imagenes[selIndex].Import(bmp, info.type == 1, ref palette))
                {
                    // Update structures
                    if (palette != this.info.paleta.colores && palette != null)
                    {
                        this.info.paleta.Update(palette);
                    }
                    imagenes[selIndex] = (Bitmap)info.imagenes[selIndex].bitmap.Clone();
                    if (checkBox1.Checked)
                    {
                        imagenes[selIndex].MakeTransparent();
                    }
                    infoPicture1.UpdateSelected(info.imagenes[selIndex]);
                    infoPicture1.Imagen_Seleccionada = selIndex;

                    // Write file
                    string tempFile = this.pluginHost.Get_TempFile();
                    Ani.SaveToFile(this.info, tempFile);

                    // Compress file
                    string compressedFile = this.pluginHost.Get_TempFile();
                    this.pluginHost.Compress(tempFile, compressedFile, FormatCompress.LZ10);

                    System.IO.BinaryWriter bw = new System.IO.BinaryWriter(System.IO.File.OpenWrite(tempFile));
                    bw.BaseStream.SetLength(0);
                    bw.Write((uint)2);
                    bw.Write(System.IO.File.ReadAllBytes(compressedFile));
                    bw.Close();
                    System.IO.File.Delete(compressedFile);

                    this.pluginHost.ChangeFile(id, tempFile);
                }
            }
        }
示例#2
0
文件: InfoAni.cs 项目: MetLob/tinke
        public InfoAni(Ani.Todo info, IPluginHost pluginHost)
        {
            InitializeComponent();
            this.pluginHost = pluginHost;
            LeerIdioma();

            this.info = info;
            infoPicture1.Idioma = pluginHost.Get_Language();
            infoPicture1.Informacion = info;
            imagenes = new Bitmap[info.imgs];
            for (int i = 0; i < info.imgs; i++)
            {
                comboBox1.Items.Add(info.imagenes[i].name);
                imagenes[i] = (Bitmap)info.imagenes[i].bitmap.Clone();
            }

            comboBox1.SelectedIndex = 0;
            pictureBox1.Image = imagenes[0];
        }