示例#1
0
        private void buttonMake_Click(object sender, System.EventArgs e)
        {
            ClearErrorLabel( );
            buttonMake.Enabled        = false;
            buttonRemove.Enabled      = false;
            buttonRemoveMulti.Enabled = false;
            buttonInsert.Enabled      = false;
            buttonInsertMulti.Enabled = false;
            buttonCompact.Enabled     = false;

            if (System.IO.File.Exists(strMPFile))
            {
                System.IO.File.Delete(strMPFile);
            }
            if (System.IO.File.Exists(strMP2File))
            {
                System.IO.File.Delete(strMP2File);
            }
            try
            {
                Accusoft.ImagXpressSdk.ImageX imgTmp = null;

                // Create file with first page
                imgTmp = Accusoft.ImagXpressSdk.ImageX.FromFile(imagXpress1, strImageFile1);
                Accusoft.ImagXpressSdk.SaveOptions soOpts = new Accusoft.ImagXpressSdk.SaveOptions();

                soOpts.Format           = Accusoft.ImagXpressSdk.ImageXFormat.Tiff;
                soOpts.Tiff.Compression = Accusoft.ImagXpressSdk.Compression.NoCompression;
                soOpts.Tiff.MultiPage   = true;
                imgTmp.Save(strMPFile, soOpts);
                imgTmp.Dispose();
                imgTmp = null;

                // Insert pages 2 and 3
                Accusoft.ImagXpressSdk.ImageX.InsertPage(imagXpress1, strImageFile2, strMPFile, 2);
                Accusoft.ImagXpressSdk.ImageX.InsertPage(imagXpress1, strImageFile3, strMPFile, 3);
                // Make an identical copy for multi-page inserts
                System.IO.File.Copy(strMPFile, strMP2File);

                buttonRemove.Enabled      = true;
                buttonRemoveMulti.Enabled = true;
                buttonMake.Enabled        = true;
            }
            catch (Accusoft.ImagXpressSdk.ImagXpressException ex)
            {
                AccusoftError(ex, lblError);
                buttonMake.Enabled = true;
                return;
            }
            ReloadViews();
        }
        private Accusoft.ImagXpressSdk.ImageX SaveIXMultiPage(string p_fileName)
        {
            //m_filePath = m_currentDir + @"\" + p_fileName;
            m_filePath    = p_fileName;
            m_saveOptions = new Accusoft.ImagXpressSdk.SaveOptions();
            try
            {
                try
                {
                    var imgList = new List <string>();
                    m_numPages = Accusoft.ImagXpressSdk.ImageX.NumPages(imagXpress1, m_filePath); //changed loop
                    for (int i = 0; i < 3; i++)
                    {
                        if (i == 0)
                        {
                            ImageLoad(m_filePath, 1);
                            imageXView1.Image = m_imagXpressObject;
                        }

                        imageXView1.Image = Accusoft.ImagXpressSdk.ImageX.FromFile(imagXpress1, m_filePath, i);
                        SaveIX("MTIFF");
                    }
                }
                catch (Accusoft.ImagXpressSdk.ImagXpressException m_ex)
                {
                    AccusoftError(m_ex, label1);
                    throw;
                }
            }
            catch (Exception p_ex)
            {
                string _msg = String.Format(" Please load image file. Ex Message: {0}", p_ex.Message);
                listBox1.Items.Add(_msg);
            }
            return(null);
        }
        private Accusoft.ImagXpressSdk.ImageX SaveIX(string p_fileType)
        {
            if (p_fileType != "")
            {
                m_fileType = p_fileType;
            }
            else
            {
                m_fileType = comboBox1.Text;
            }
            m_saveOptions = new Accusoft.ImagXpressSdk.SaveOptions();

            switch (m_fileType)
            {
            case "JPEG":
                try
                {
                    try
                    {
                        m_saveOptions.Format = Accusoft.ImagXpressSdk.ImageXFormat.Jpeg;
                        imageXView1.Image.Save(@"D:\test\testinghah.jpeg", m_saveOptions);
                        listBox1.Items.Add("File saved to JPEG file format.");
                        return(m_imagXpressObject);
                    }
                    catch (Accusoft.ImagXpressSdk.ImagXpressException m_ex)
                    {
                        AccusoftError(m_ex, label1);
                        throw;
                    }
                }
                catch (Exception p_ex)
                {
                    string _msg = String.Format("Saving file fail. Ex Message: {0}", p_ex.Message);
                    listBox1.Items.Add(_msg);
                }
                break;

            case "BMP":
                try
                {
                    try
                    {
                        m_saveOptions.Format = Accusoft.ImagXpressSdk.ImageXFormat.Bmp;
                        imageXView1.Image.Save(@"D:\test\testinghah.bmp", m_saveOptions);
                        listBox1.Items.Add("File saved to BMP file format.");
                        return(m_imagXpressObject);
                    }
                    catch (Accusoft.ImagXpressSdk.ImagXpressException m_ex)
                    {
                        AccusoftError(m_ex, label1);
                        throw;
                    }
                }
                catch (Exception p_ex)
                {
                    string _msg = String.Format("Saving file fail. Ex Message: {0}", p_ex.Message);
                    listBox1.Items.Add(_msg);
                }
                break;

            case "TIFF":
                try
                {
                    try
                    {
                        m_saveOptions.Format = Accusoft.ImagXpressSdk.ImageXFormat.Tiff;
                        imageXView1.Image.Save(@"D:\test\testinghah.tiff", m_saveOptions);
                        listBox1.Items.Add("File saved to TIFF file format.");
                        return(m_imagXpressObject);
                    }
                    catch (Accusoft.ImagXpressSdk.ImagXpressException m_ex)
                    {
                        AccusoftError(m_ex, label1);
                        throw;
                    }
                }
                catch (Exception p_ex)
                {
                    string _msg = String.Format("Saving file fail. Ex Message: {0}", p_ex.Message);
                    listBox1.Items.Add(_msg);
                }
                break;

            case "PNG":
                try
                {
                    try
                    {
                        m_saveOptions.Format = Accusoft.ImagXpressSdk.ImageXFormat.Png;
                        imageXView1.Image.Save(@"D:\test\testinghah.png", m_saveOptions);
                        listBox1.Items.Add("File saved to PNG file format.");
                        return(m_imagXpressObject);
                    }
                    catch (Accusoft.ImagXpressSdk.ImagXpressException m_ex)
                    {
                        AccusoftError(m_ex, label1);
                        throw;
                    }
                }
                catch (Exception p_ex)
                {
                    string _msg = String.Format("Saving file fail. Ex Message: {0}", p_ex.Message);
                    listBox1.Items.Add(_msg);
                }
                break;

            case "MTIFF":
                try
                {
                    try
                    {
                        m_saveOptions.Tiff.MultiPage = true;
                        m_saveOptions.Format         = Accusoft.ImagXpressSdk.ImageXFormat.Tiff;
                        imageXView1.Image.Save(@"D:\test\testMimg3.tiff", m_saveOptions);
                        listBox1.Items.Add("Multi-TIFF file format saved.");
                        return(m_imagXpressObject);
                    }
                    catch (Accusoft.ImagXpressSdk.ImagXpressException m_ex)
                    {
                        AccusoftError(m_ex, label1);
                        throw;
                    }
                }
                catch (Exception p_ex)
                {
                    string _msg = String.Format("Saving file fail. Ex Message: {0}", p_ex.Message);
                    listBox1.Items.Add(_msg);
                }
                break;

            default:
                listBox1.Items.Add("Save Failed. Please select a File Type.");
                break;
            }
            return(m_imagXpressObject);
        }
示例#4
0
        private void cmdSave_Click(object sender, System.EventArgs e)
        {
            Accusoft.ImagXpressSdk.SaveOptions so = new Accusoft.ImagXpressSdk.SaveOptions();
            string saveDirectory = Application.StartupPath;

            switch (cmbSave.SelectedIndex)
            {
            //BMP
            case 0:
                try
                {
                    so.Format = Accusoft.ImagXpressSdk.ImageXFormat.Bmp;
                    imageXView1.Image.Save(saveDirectory + @"\temp.bmp", so);
                }
                catch (Accusoft.ImagXpressSdk.ImagXpressException eX)
                {
                    AccusoftError(eX, lblError);
                }
                catch (System.IO.FileLoadException eX)
                {
                    AccusoftError(eX, lblError);
                }
                catch (System.Exception eX)
                {
                    AccusoftError(eX, lblError);
                }
                break;

            //JPG
            case 1:

                try
                {
                    so.Format           = Accusoft.ImagXpressSdk.ImageXFormat.Jpeg;
                    so.Jpeg.Luminance   = 13;
                    so.Jpeg.Chrominance = 13;
                    so.Jpeg.SubSampling = Accusoft.ImagXpressSdk.SubSampling.SubSampling111;
                    imageXView1.Image.Save(saveDirectory + @"\temp.jpg", so);
                }
                catch (Accusoft.ImagXpressSdk.ImagXpressException eX)
                {
                    AccusoftError(eX, lblError);
                }
                catch (System.IO.FileLoadException eX)
                {
                    AccusoftError(eX, lblError);
                }
                catch (System.Exception eX)
                {
                    AccusoftError(eX, lblError);
                }
                break;

            //TIFF
            case 2:

                try
                {
                    so.Format           = Accusoft.ImagXpressSdk.ImageXFormat.Tiff;
                    so.Tiff.Compression = Accusoft.ImagXpressSdk.Compression.Group4;
                    imageXView1.Image.Save(saveDirectory + @"\temp.tiff", so);
                }
                catch (Accusoft.ImagXpressSdk.ImagXpressException eX)
                {
                    AccusoftError(eX, lblError);
                }
                catch (System.IO.FileLoadException eX)
                {
                    AccusoftError(eX, lblError);
                }
                catch (System.Exception eX)
                {
                    AccusoftError(eX, lblError);
                }
                break;


            default: break;
            }
        }