当前位置: 首页>>代码示例>>C#>>正文


C# Bitmap.SaveAdd方法代码示例

本文整理汇总了C#中System.Drawing.Bitmap.SaveAdd方法的典型用法代码示例。如果您正苦于以下问题:C# Bitmap.SaveAdd方法的具体用法?C# Bitmap.SaveAdd怎么用?C# Bitmap.SaveAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Bitmap的用法示例。


在下文中一共展示了Bitmap.SaveAdd方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: saveImage

        private void saveImage()
        {
            if (checkPath())
            {
                Guid newImageGuid = Guid.NewGuid();

                _objImage.Dispose();
                _objImage = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();

                string newStrFilePath = _strPath + newImageGuid + ".tif";

                // Ridenomino tutti i frame col nuovo GUID
                int firstFrameIndex = 0;
                bool first = true;
                for (int z = 0; z <= _totFrame; z++)
                {
                    try
                    {
                        if (File.Exists(_strPath + _imageGuid + "_" + z + ".tif"))
                        {
                            File.Move(_strPath + _imageGuid + "_" + z + ".tif", _strPath + newImageGuid + "_" + z + ".tif");
                            File.Delete(_strPath + _imageGuid + "_" + z + ".tif");
                            if (first)
                            {
                                firstFrameIndex = z;
                                first = false;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                }

                Bitmap saveTif = new Bitmap(_strPath + newImageGuid + "_" + firstFrameIndex + ".tif");

                ImageCodecInfo myImageCodecInfo = GetEncoderInfo("image/tiff");
                System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.SaveFlag;
                EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, (long)EncoderValue.MultiFrame);
                EncoderParameters myEncoderParameters = new EncoderParameters(1);
                myEncoderParameters.Param[0] = myEncoderParameter;
                saveTif.Save(newStrFilePath, myImageCodecInfo, myEncoderParameters);

                for (int z = firstFrameIndex + 1; z <= _totFrame; z++)
                {
                    try
                    {
                        if (File.Exists(_strPath + newImageGuid + "_" + z + ".tif"))
                        {
                            Bitmap saveFrame = new Bitmap(_strPath + newImageGuid + "_" + z + ".tif");
                            myEncoderParameter = new EncoderParameter(myEncoder, (long)EncoderValue.FrameDimensionPage);
                            myEncoderParameters.Param[0] = myEncoderParameter;
                            saveTif.SaveAdd(saveFrame, myEncoderParameters);
                            saveFrame.Dispose();
                            File.Delete(_strPath + newImageGuid + "_" + z + ".tif");
                        }

                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                }

                saveTif.Dispose();
                File.Delete(_strPath + newImageGuid + "_" + firstFrameIndex + ".tif");
                _strFilePath = newStrFilePath;
                Guid oldGuid = _imageGuid;
                _curF = 0;
                loadImage(newImageGuid);
                File.Delete(_strPath + oldGuid + ".tif");
            }
        }
开发者ID:gipasoft,项目名称:Sfera,代码行数:76,代码来源:GestioneFax.cs

示例2: saveMultiframeTIF

        public static void saveMultiframeTIF( string strFN, Bitmap bmpLarge, Bitmap bmpSmall )
        {
            ImageCodecInfo myImageCodecInfo;
            Encoder myEncoder;
            EncoderParameter myEncoderParameter;
            EncoderParameters myEncoderParameters;

            // Get an ImageCodecInfo object that represents the TIFF codec.
            myImageCodecInfo = GetEncoderInfo("image/tiff");
            // Create an Encoder object based on the GUID
            // for the SaveFlag parameter category.
            myEncoder = Encoder.SaveFlag;
            // Create an EncoderParameters object.
            // An EncoderParameters object has an array of EncoderParameter
            // objects. In this case, there is only one
            // EncoderParameter object in the array.

            myEncoderParameters = new EncoderParameters(1);
            // Save the first page (frame).
            myEncoderParameter = new EncoderParameter( myEncoder, (long)EncoderValue.MultiFrame );
            myEncoderParameters.Param[0] = myEncoderParameter;

            Image imgFile = new Bitmap( bmpSmall );
            imgFile.Save( strFN, myImageCodecInfo, myEncoderParameters);

            // Save the second page (frame).
            myEncoderParameter = new EncoderParameter( myEncoder, (long)EncoderValue.FrameDimensionPage );
            myEncoderParameters.Param[0] = myEncoderParameter;
            imgFile.SaveAdd( bmpLarge, myEncoderParameters );

            imgFile.Dispose();
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:32,代码来源:Util.cs

示例3: PrintToTifFile

        public void PrintToTifFile(string fileName)
        {
            try
            {
                // Compute bitmap propertiy about same as default printer
                PrintDocument pd = new PrintDocument();
                InitPrinting(ref pd);
                System.Drawing.Bitmap bitmapAllPages, bitmapAdditionnalPage;
                bitmapAllPages = new Bitmap(pd.DefaultPageSettings.Bounds.Width, pd.DefaultPageSettings.Bounds.Height);
                bitmapAdditionnalPage = new Bitmap(pd.DefaultPageSettings.Bounds.Width, pd.DefaultPageSettings.Bounds.Height);
                Graphics g;

                //Prepare parameters to save multiframe image
                System.Drawing.Imaging.EncoderParameters eps;
                eps = new System.Drawing.Imaging.EncoderParameters();
                bool firstPage = true;

                // Print pages
                do
                {
                    if (firstPage)
                        g = Graphics.FromImage(bitmapAllPages);
                    else
                        g = Graphics.FromImage(bitmapAdditionnalPage);
                    g.Clear(System.Drawing.Color.White);
                    _MultiPage.NewPage(g);
                    Single extendedHeight;
                    Single y;

                    y = 0;
                    extendedHeight = 0;
                    bool scanForChildControls;
                    if (DelegatePrintingReportTitle == null)
                        PrintReportTitle(_f, ParentControlPrinting.BeforeChilds , _MultiPage, _xform, y, ref extendedHeight, out scanForChildControls);
                    else
                        DelegatePrintingReportTitle(_f, ParentControlPrinting.BeforeChilds , _MultiPage, _xform, y, ref extendedHeight, out scanForChildControls);
                    y += extendedHeight;

                    // Print each control on the form
                    Single globalExtendedHeight;
                    PrintControls(_f, _MultiPage, _xform, y, out globalExtendedHeight);

                    if(firstPage)
                    {
                        //Create the parameter and choose multi-frame
                        eps.Param[0]=new EncoderParameter(Encoder.SaveFlag,(long)EncoderValue.MultiFrame);
                        //Get the correct encoder from the list of available encoders
                        ImageCodecInfo[] infos=ImageCodecInfo.GetImageEncoders();
                        int n=0;
                        while(infos[n].MimeType!="image/tiff")
                            n++;
                        //save the first page
                        bitmapAllPages.Save(fileName + ".tif",infos[n],eps);
                    }
                    else
                    {
                        //Create the parameter and choose FrameDimensionPage
                        eps.Param[0]=new EncoderParameter(Encoder.SaveFlag,(long)EncoderValue.FrameDimensionPage);
                        //save the first page
                        bitmapAllPages.SaveAdd(bitmapAdditionnalPage,eps);
                    }
                    firstPage = false;
                } while (!_MultiPage.LastPage());

                // Flush pages to file
                eps.Param[0]=new EncoderParameter(Encoder.SaveFlag,(long)EncoderValue.Flush);
                bitmapAllPages.SaveAdd(eps);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
开发者ID:gregggdavis,项目名称:schedww2,代码行数:73,代码来源:clsFormPrinting.cs

示例4: SetNewSize

        internal void SetNewSize(Size size, string sizeMode)
        {
            Point destLocation = getDestinationPos(size, sizeMode);
            Bitmap newSrcImage = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb);
            Graphics g = Graphics.FromImage(newSrcImage);
            Brush fondo = new SolidBrush(preferences.SrcBackgroundColor);

            FrameDimension frameDimensions = new FrameDimension(newSrcImage.FrameDimensionsList[0]);
            FrameDimension oldFrameDimensions = new FrameDimension(this.srcImage.FrameDimensionsList[0]);

            EncoderParameters tiffParams = new EncoderParameters(1);
            EncoderParameter param = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, (long)EncoderValue.MultiFrame);
            tiffParams.Param[0] = param;

            ImageCodecInfo tiffEncoder = getCodecInfo("image/tiff");

            string filePath = System.IO.Path.GetTempFileName();

            for (int frame = 0; frame < numFrames; frame++)
            {
                Bitmap tempImage = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb);
                Graphics tempGr = Graphics.FromImage(tempImage);

                this.srcImage.SelectActiveFrame(oldFrameDimensions, frame);
                tempGr.FillRectangle(fondo, 0, 0, newSrcImage.Width, newSrcImage.Height);
                tempGr.DrawImage(this.srcImage, destLocation);

                if (frame == 0)
                {
                    g.DrawImage(this.srcImage, destLocation);
                    newSrcImage.Save(filePath, tiffEncoder, tiffParams);
                }
                else
                {
                    tiffParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag,
                        (long)EncoderValue.FrameDimensionPage);
                    newSrcImage.SaveAdd(tempImage, tiffParams);
                }

                tempImage.Dispose();
                GC.Collect();
            }
            tiffParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag,
                                            (long)EncoderValue.Flush);
            newSrcImage.SaveAdd(tiffParams);
            newSrcImage.Dispose();
            GC.Collect();

            Image temp = this.srcImage;
            this.SrcImage = Bitmap.FromFile(filePath);

            temp.Dispose();
            fondo.Dispose();
            g.Dispose();
        }
开发者ID:AugustoRuiz,项目名称:Gif2Sheet,代码行数:55,代码来源:frmProcessImage.cs

示例5: SaveBitmap

        private void SaveBitmap(Bitmap tif, Bitmap bm, Stream st, int pageNo)
        {
            if (pageNo == 1)
            {
                // Handling saving first page 

                // STEP: Prepare ImageCodecInfo for saving 
                ImageCodecInfo info = null;

                foreach (ImageCodecInfo i in ImageCodecInfo.GetImageEncoders())
                {
                    if (i.MimeType == "image/tiff")
                    {
                        info = i;
                        break;
                    }
                }

                // STEP: Prepare parameters 
                EncoderParameters encoderParams = new EncoderParameters(2);

                encoderParams.Param[0] = new EncoderParameter(
                    System.Drawing.Imaging.Encoder.SaveFlag, (long)EncoderValue.MultiFrame
                );

                encoderParams.Param[1] = new EncoderParameter(
                    System.Drawing.Imaging.Encoder.Compression, 
                    (long)(_RenderColor? EncoderValue.CompressionLZW: EncoderValue.CompressionCCITT3)
                );

                // STEP: Save bitmap 
                tif.Save(st, info, encoderParams);
            }
            else
            {
                // STEP: Prepare parameters 
                EncoderParameters encoderParams = new EncoderParameters(1);

                encoderParams.Param[0] = new EncoderParameter(
                    System.Drawing.Imaging.Encoder.SaveFlag, (long)EncoderValue.FrameDimensionPage
                );

                // STEP: Save bitmap 
                tif.SaveAdd(bm, encoderParams);
            }
        }
开发者ID:myersBR,项目名称:My-FyiReporting,代码行数:46,代码来源:RenderTif.cs

示例6: AddFrameToImage

        private static void AddFrameToImage(Bitmap ImageToSaveInto, Bitmap ImageToAdd, int FrameId, EncoderParameters EncodeParameters)
        {
            //set the active page
            ImageToAdd.SelectActiveFrame(FrameDimension.Page, FrameId);

            //add the page to the image
            ImageToSaveInto.SaveAdd(ImageToAdd, EncodeParameters);
        }
开发者ID:dibiancoj,项目名称:ToracLibrary,代码行数:8,代码来源:TiffCombiner.cs

示例7: saveImageExistingMultiplePage

        private static void saveImageExistingMultiplePage(Image[] bmp, Image origionalFile, int PageNumber, string location)
        {
            try
            {
                //Now load the Codecs
                ImageCodecInfo codecInfo = getCodec();

                Encoder saveEncoder;
                Encoder compressionEncoder;
                EncoderParameter saveEncodeParam;
                EncoderParameter compressionEncodeParam;
                EncoderParameters encoderParams = new EncoderParameters(2);
                Bitmap pages;
                Bitmap nextPage;

                saveEncoder = Encoder.SaveFlag;
                compressionEncoder = Encoder.Compression;

                origionalFile.SelectActiveFrame(FrameDimension.Page, 0);
                pages = new Bitmap(origionalFile);
                pages = ConvertToBitonal(pages);

                // Save the first page (frame).
                saveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.MultiFrame);
                compressionEncodeParam = new EncoderParameter(compressionEncoder, (long)EncoderValue.CompressionCCITT4);
                encoderParams.Param[0] = compressionEncodeParam;
                encoderParams.Param[1] = saveEncodeParam;

                pages.Save(location, codecInfo, encoderParams);

                for (int i = 1; i < PageNumber; i++)
                {
                    saveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.FrameDimensionPage);
                    compressionEncodeParam = new EncoderParameter(compressionEncoder, (long)EncoderValue.CompressionCCITT4);
                    encoderParams.Param[0] = compressionEncodeParam;
                    encoderParams.Param[1] = saveEncodeParam;

                    origionalFile.SelectActiveFrame(FrameDimension.Page, i);
                    nextPage = new Bitmap(origionalFile);
                    nextPage = ConvertToBitonal(nextPage);
                    pages.SaveAdd(nextPage, encoderParams);
                }

                for (int i = 0; i < bmp.Length; i++)
                {
                    saveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.FrameDimensionPage);
                    compressionEncodeParam = new EncoderParameter(compressionEncoder, (long)EncoderValue.CompressionCCITT4);
                    encoderParams.Param[0] = compressionEncodeParam;
                    encoderParams.Param[1] = saveEncodeParam;
                    bmp[i] = (Bitmap)ConvertToBitonal((Bitmap)bmp[i]);
                    pages.SaveAdd(bmp[i], encoderParams);
                }

                saveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.Flush);
                encoderParams.Param[0] = saveEncodeParam;
                pages.SaveAdd(encoderParams);
            }
            catch (System.Exception ee)
            {
                throw ee;
            }
        }
开发者ID:fizikci,项目名称:Cinar,代码行数:62,代码来源:Tiff.cs


注:本文中的System.Drawing.Bitmap.SaveAdd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。