コード例 #1
0
        private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openPic = new OpenFileDialog();

            if (openPic.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    pcx openPcx = new pcx(openPic.FileName);
                    pictureBox1.Image = openPcx.PcxImage;
                    currentimage      = openPcx.PcxImage;
                    label1.Text       = string.Format("FileName: {0}     Dimension:{1}x{2}", Path.GetFileName(openPic.FileName)
                                                      , openPcx.header.Width.ToString(), openPcx.header.Height.ToString());
                    function.Draw_Histogram(currentimage, ref pictureBox4);
                    label33.Text = openPcx.header.Manufacturer.ToString();
                    label32.Text = openPcx.header.Version.ToString();
                    label31.Text = openPcx.header.Encoding.ToString();
                    label30.Text = openPcx.header.Bits_Per_Pixel.ToString();
                    label29.Text = openPcx.header.Xmin.ToString();
                    label28.Text = openPcx.header.Ymin.ToString();
                    label27.Text = openPcx.header.Xmax.ToString();
                    label26.Text = openPcx.header.Ymax.ToString();
                    label25.Text = openPcx.header.Hres1.ToString();
                    label24.Text = openPcx.header.Vres1.ToString();
                    label23.Text = openPcx.header.Reserved.ToString();
                    label22.Text = openPcx.header.Colour_Planes.ToString();
                    label21.Text = openPcx.header.Bytes_Per_Line.ToString();
                    label20.Text = openPcx.header.Palette_Type.ToString();
                    int hs = openPcx.header.HscreenSize + openPcx.header.HscreenSize1 * 256;
                    int vs = openPcx.header.VscreenSize + openPcx.header.VscreenSize1 * 256;
                    label19.Text = hs.ToString();
                    label18.Text = vs.ToString();
                    FileStream file = new FileStream(openPic.FileName, FileMode.Open);
                    int        dl   = System.Convert.ToInt32(file.Length);
                    int        n    = 0;
                    for (int y = 0; y < color.Height; y++)//調色盤
                    {
                        for (int x = 0; x < color.Width; x++)
                        {
                            n = (dl - 768) + (((y / 25) * 16 + (x / 25)) * 3);//0~24都是同一個color map 格子 8/8/8
                            color.SetPixel(x, y, Color.FromArgb(openPcx.data[n], openPcx.data[n + 1], openPcx.data[n + 2]));
                        }
                    }
                    pictureBox5.Image = color;
                    functionToolStripMenuItem.Enabled = true;
                    filterToolStripMenuItem.Enabled   = true;
                }
                catch (NullReferenceException ex) { MessageBox.Show(ex.Message); }
            }
        }
コード例 #2
0
        public Form4(Image img)
        {
            InitializeComponent();
            img1 = (Bitmap)img;
            OpenFileDialog openPic = new OpenFileDialog();

            if (openPic.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    pcx openPcx = new pcx(openPic.FileName);
                    img2 = openPcx.PcxImage;
                }
                catch (NullReferenceException ex) { MessageBox.Show(ex.Message); }
            }
            pictureBox1.Image = img1;
            pictureBox2.Image = img2;
        }