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

            o.CheckFileExists = true;
            o.Filter          = "All supported formats|*.pal;*.aco;*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon|" +
                                "Windows Palette (*.pal)|*.pal|" +
                                "Adobe COlor (*.aco)|*.aco|" +
                                "Palette from image|*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon";
            if (o.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string ext = Path.GetExtension(o.FileName).ToLower();

            if (string.IsNullOrEmpty(ext) || ext.Length == 0)
            {
                MessageBox.Show("File without extension... Aborting");
                return;
            }

            if (ext.Contains("."))
            {
                ext = ext.Substring(ext.LastIndexOf(".") + 1);
            }
            Console.WriteLine("File extension:" + ext);
            PaletteBase newpal;

            if (ext == "pal")
            {
                newpal = new Formats.PaletteWin(o.FileName);
            }
            else if (ext == "aco")
            {
                newpal = new Formats.ACO(o.FileName);
            }
            else
            {
                byte[]  tiles;
                Color[] newcol;
                Actions.Indexed_Image((Bitmap)Image.FromFile(o.FileName), palette.Depth, out tiles, out newcol);
                newpal = new RawPalette(newcol, palette.CanEdit, palette.Depth);
            }

            if (newpal != null)
            {
                palette.Set_Palette(newpal);
            }

            // Write the file
            Write_File();

            o.Dispose();
            o = null;
        }
예제 #2
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            SaveFileDialog o = new SaveFileDialog();

            o.CheckFileExists = true;
            o.Filter          = "All supported formats|*.pal;*.aco;*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon|" +
                                "Windows Palette (*.pal)|*.pal|" +
                                "Adobe COlor (*.aco)|*.aco|" +
                                "Palette from image|*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon";
            if (o.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string      ext = Path.GetExtension(o.FileName).ToLower();
            PaletteBase newpal;

            if (ext == "pal")
            {
                newpal = new Formats.PaletteWin(o.FileName);
            }
            else if (ext == "aco")
            {
                newpal = new Formats.ACO(o.FileName);
            }
            else
            {
                byte[]  tiles;
                Color[] newcol;
                Actions.Indexed_Image((Bitmap)Image.FromFile(o.FileName), palette.Depth, out tiles, out newcol);
                newpal = new RawPalette(newcol, palette.CanEdit, palette.Depth);
            }

            if (newpal != null)
            {
                palette.Set_Palette(newpal);
            }

            // Write the file
            Write_File();

            o.Dispose();
            o = null;
        }
예제 #3
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog o = new SaveFileDialog();

            o.AddExtension    = true;
            o.CheckPathExists = true;
            o.DefaultExt      = ".pal";
            o.Filter          = "Windows Palette for Gimp 2.8 (*.pal)|*.pal|" +
                                "Windows Palette (*.pal)|*.pal|" +
                                "Portable Network Graphics (*.png)|*.png|" +
                                "Adobe COlor (*.aco)|*.aco";
            o.OverwritePrompt = true;
            o.FileName        = palette.FileName;

            if (o.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (o.FilterIndex == 3)
            {
                picPalette.Image.Save(o.FileName, System.Drawing.Imaging.ImageFormat.Png);
            }
            else if (o.FilterIndex == 1 || o.FilterIndex == 2)
            {
                Formats.PaletteWin palwin = new Formats.PaletteWin(palette.Palette[(int)numericPalette.Value]);
                if (o.FilterIndex == 1)
                {
                    palwin.Gimp_Error = true;
                }
                palwin.Write(o.FileName);
            }
            else if (o.FilterIndex == 4)
            {
                Formats.ACO palaco = new Formats.ACO(palette.Palette[(int)numericPalette.Value]);
                palaco.Write(o.FileName);
            }

            o.Dispose();
            o = null;
        }
예제 #4
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog o = new SaveFileDialog();
            o.AddExtension = true;
            o.CheckPathExists = true;
            o.DefaultExt = ".pal";
            o.Filter = "Windows Palette for Gimp 2.8 (*.pal)|*.pal|" +
                        "Windows Palette (*.pal)|*.pal|" +
                        "Portable Network Graphics (*.png)|*.png|" +
                        "Adobe COlor (*.aco)|*.aco";
            o.OverwritePrompt = true;
            o.FileName = palette.FileName;

            if (o.ShowDialog() != DialogResult.OK)
                return;

            if (o.FilterIndex == 3)
                picPalette.Image.Save(o.FileName, System.Drawing.Imaging.ImageFormat.Png);
            else if (o.FilterIndex == 1 || o.FilterIndex == 2)
            {
                Formats.PaletteWin palwin = new Formats.PaletteWin(palette.Palette[(int)numericPalette.Value]);
                if (o.FilterIndex == 1) palwin.Gimp_Error = true;
                palwin.Write(o.FileName);
            }
            else if (o.FilterIndex == 4)
            {
                Formats.ACO palaco = new Formats.ACO(palette.Palette[(int)numericPalette.Value]);
                palaco.Write(o.FileName);
            }

            o.Dispose();
            o = null;
        }
예제 #5
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog o = new OpenFileDialog();
            o.CheckFileExists = true;
            o.Filter = "All supported formats|*.pal;*.aco;*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon|" +
                "Windows Palette (*.pal)|*.pal|" +
                "Adobe COlor (*.aco)|*.aco|" +
                "Palette from image|*.png;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.ico;*.icon";
            if (o.ShowDialog() != DialogResult.OK)
                return;

            string ext = Path.GetExtension(o.FileName).ToLower();
            if (string.IsNullOrEmpty(ext) || ext.Length == 0) {
                MessageBox.Show("File without extension... Aborting");
                return;
            }

            if (ext.Contains("."))
                ext = ext.Substring(ext.LastIndexOf(".") + 1);
            Console.WriteLine("File extension:" + ext);
            PaletteBase newpal;

            if (ext == "pal")
                newpal = new Formats.PaletteWin(o.FileName);
            else if (ext == "aco")
                newpal = new Formats.ACO(o.FileName);
            else
            {
                byte[] tiles;
                Color[] newcol;
                Actions.Indexed_Image((Bitmap)Image.FromFile(o.FileName), palette.Depth, out tiles, out newcol);
                newpal = new RawPalette(newcol, palette.CanEdit, palette.Depth);
            }

            if (newpal != null)
                palette.Set_Palette(newpal);

            // Write the file
            Write_File();

            o.Dispose();
            o = null;
        }