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


C# EncoderParameters.ConvertToMemory方法代码示例

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


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

示例1: SaveAdd

        public void SaveAdd(Image image, EncoderParameters encoderParams) {
            IntPtr encoder = IntPtr.Zero;

            if (image == null) {
                throw new ArgumentNullException("image");
            }
            if (encoderParams != null) {
                encoder = encoderParams.ConvertToMemory();
            }

            rawData = null;
            int status = SafeNativeMethods.Gdip.GdipSaveAddImage(new HandleRef(this, nativeImage), new HandleRef(image, image.nativeImage), new HandleRef(encoderParams, encoder));

            if (encoder != IntPtr.Zero){
                Marshal.FreeHGlobal(encoder);
            }
            if (status != SafeNativeMethods.Gdip.Ok) {
                throw SafeNativeMethods.Gdip.StatusException(status);
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:20,代码来源:Image.cs

示例2: Save

        public void Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) {
            if (stream == null){
                throw new ArgumentNullException("stream");
            }
            if (encoder == null) {
                throw new ArgumentNullException("encoder");
            }

            IntPtr encoderParamsMemory = IntPtr.Zero;

            if (encoderParams != null) {
                rawData = null;
                encoderParamsMemory = encoderParams.ConvertToMemory();
            }

            int status = SafeNativeMethods.Gdip.Ok;

            try {
                Guid g = encoder.Clsid;
                bool saved = false;

                if (rawData != null) {
                    ImageCodecInfo rawEncoder = RawFormat.FindEncoder();
                    if (rawEncoder != null && rawEncoder.Clsid == g) {
                        stream.Write(rawData, 0, rawData.Length);
                        saved = true;
                    }
                }

                if (!saved) {
                    status = SafeNativeMethods.Gdip.GdipSaveImageToStream(new HandleRef(this, nativeImage),
                                                                     new UnsafeNativeMethods.ComStreamFromDataStream(stream),
                                                                     ref g,
                                                                     new HandleRef(encoderParams, encoderParamsMemory));
                }
            }
            finally {
                if (encoderParamsMemory != IntPtr.Zero) {
                    Marshal.FreeHGlobal(encoderParamsMemory);
                }
            }
            
            if (status != SafeNativeMethods.Gdip.Ok) {
                throw SafeNativeMethods.Gdip.StatusException(status);
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:46,代码来源:Image.cs

示例3: SaveAdd

 public void SaveAdd(EncoderParameters encoderParams)
 {
     IntPtr zero = IntPtr.Zero;
     if (encoderParams != null)
     {
         zero = encoderParams.ConvertToMemory();
     }
     this.rawData = null;
     int status = SafeNativeMethods.Gdip.GdipSaveAdd(new HandleRef(this, this.nativeImage), new HandleRef(encoderParams, zero));
     if (zero != IntPtr.Zero)
     {
         Marshal.FreeHGlobal(zero);
     }
     if (status != 0)
     {
         throw SafeNativeMethods.Gdip.StatusException(status);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:18,代码来源:Image.cs

示例4: Save

 public void Save(string filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
 {
     if (filename == null)
     {
         throw new ArgumentNullException("filename");
     }
     if (encoder == null)
     {
         throw new ArgumentNullException("encoder");
     }
     System.Drawing.IntSecurity.DemandWriteFileIO(filename);
     IntPtr zero = IntPtr.Zero;
     if (encoderParams != null)
     {
         this.rawData = null;
         zero = encoderParams.ConvertToMemory();
     }
     int status = 0;
     try
     {
         Guid clsid = encoder.Clsid;
         bool flag = false;
         if (this.rawData != null)
         {
             ImageCodecInfo info = this.RawFormat.FindEncoder();
             if ((info != null) && (info.Clsid == clsid))
             {
                 using (FileStream stream = File.OpenWrite(filename))
                 {
                     stream.Write(this.rawData, 0, this.rawData.Length);
                     flag = true;
                 }
             }
         }
         if (!flag)
         {
             status = SafeNativeMethods.Gdip.GdipSaveImageToFile(new HandleRef(this, this.nativeImage), filename, ref clsid, new HandleRef(encoderParams, zero));
         }
     }
     finally
     {
         if (zero != IntPtr.Zero)
         {
             Marshal.FreeHGlobal(zero);
         }
     }
     if (status != 0)
     {
         throw SafeNativeMethods.Gdip.StatusException(status);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:51,代码来源:Image.cs


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