パスワードを忘れた? アカウント作成
452911 journal

Francisの日記: Tiff-jpeg変換コード

日記 by Francis
namespace image1
{
    using System;
    using System.Windows.Forms;
    using System.IO;
    using System.Net;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Drawing.Imaging;
    using System.Drawing.Text;
    using System.Reflection;

    public class ImageOne : System.Windows.Forms.Form
    {
        private System.Windows.Forms.Button button2;
        public ImageOne()
        {
            InitializeComponent();
            this.SetStyle(System.Windows.Forms.ControlStyles.Opaque, true);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            SolidBrush b=new SolidBrush(Color.White);
            g.FillRectangle(b, ClientRectangle);
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

        void InitializeComponent ()
        {
            this.button2 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            this.button2.Location = new System.Drawing.Point(36, 22);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(80, 40);
            this.button2.TabIndex = 1;
            this.button2.Text = "loadsave";
            this.button2.Click += new System.EventHandler(this.button2_Click);

            this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
            this.ClientSize = new System.Drawing.Size(152, 85);
            this.Controls.Add(this.button2);
            this.Name = "ImageOne";
            this.Text = "LzwTiff to jpeg";
            this.ResumeLayout(false);

        }
        [STAThread]
        public static void Main()
        {
            Application.Run(new ImageOne());
        }

        private void button2_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = ".\\" ;
            openFileDialog1.Filter = "tif files (*.tif)|*.tif|All files (*.*)|*.*" ;
            openFileDialog1.FilterIndex = 3 ;
            openFileDialog1.RestoreDirectory = true ;

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.Filter = "jpg(*.jpg)|*.jpg|All files (*.*)|*.*";
            saveFileDialog1.FilterIndex = 2 ;
            saveFileDialog1.InitialDirectory=".\\";
            saveFileDialog1.RestoreDirectory = true;
            if(openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if(saveFileDialog1.ShowDialog()==DialogResult.OK)
                {
                    button2.Enabled=false;
                    Bitmap a=new Bitmap(openFileDialog1.FileName,true);
                    System.Drawing.Imaging.FrameDimension oFDimension;
                    oFDimension = new System.Drawing.Imaging.FrameDimension(a.FrameDimensionsList[0]);
                    String s;
                    for(int i=0;i<a.GetFrameCount(oFDimension);i++)
                    {
                        s=saveFileDialog1.FileName;
                        s+="_Page";s+=i;s+=".jpg";
                        a.SelectActiveFrame(oFDimension,i);
                        a.Save(s,ImageFormat.Jpeg);
                    }
                    button2.Enabled=true;
                }
            }
        }
    }
}

//多分大丈夫だと思う
この議論は賞味期限が切れたので、アーカイブ化されています。 新たにコメントを付けることはできません。
typodupeerror

身近な人の偉大さは半減する -- あるアレゲ人

読み込み中...