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


C# Drawing.Save方法代码示例

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


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

示例1: BitmapToTexture

        public static Texture2D BitmapToTexture(GraphicsDevice device, Gdi.Bitmap bitmap)
        {
            MemoryStream ms = new MemoryStream();
            bitmap.Save(ms, ImageFormat.Png); // Save the bitmap to memory
            bitmap.Dispose(); // Dispose the bitmap object

            Texture2D tex = Texture2D.FromStream(device, ms); // Load the texture from the bitmap in memory
            ms.Close(); // Close the memorystream
            ms.Dispose(); // Dispose the memorystream
            return tex; // return the texture
        }
开发者ID:BryceGough,项目名称:MapleSharp,代码行数:11,代码来源:Tools.cs

示例2: ToTexture

        public static Texture2D ToTexture(drawing.Bitmap bitmap, GraphicsDevice graphicsDevice)
        {
            Texture2D texture;
            if (bitmap == null)
            {
                return null;
            }
            texture = new Texture2D(graphicsDevice, bitmap.Width, bitmap.Height);

            // MemoryStream to store the bitmap data.
            MemoryStream ms = new MemoryStream();
            // Save image to MemoryStream
            bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

            //Go to the beginning of the memory stream.
            ms.Seek(0, SeekOrigin.Begin);

            //Fill the texture.
            texture = Texture2D.FromStream(graphicsDevice, ms);

            ms.Close();
            ms.Dispose();
            ms = null;

            return texture;
        }
开发者ID:JacquesLucke,项目名称:Collage,代码行数:26,代码来源:Utils.cs

示例3: TS_SaveBitmap

 /// -------------------------------------------------------------------
 ///<summary></summary>
 /// -------------------------------------------------------------------
 void TS_SaveBitmap(Drawing.Bitmap bm)
 {
     string path = System.IO.Directory.GetCurrentDirectory() + @"\AutomationElementTest.bmp";
     Comment("Saving image to " + path);
     bm.Save(path);
     TestObject.PSFileList.Add(path);
     m_TestStep++;
 }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:11,代码来源:AutomationElementTests.cs

示例4: Render

        public override void Render(GDI.Graphics g, Map map)
        {
            if (map.Center == null)
                throw (new ApplicationException("Cannot render map. View center not specified"));

            g.SmoothingMode = SmoothingMode;
            var envelope = ToSource(map.Envelope); //View to render

            if (DataSource == null)
                throw (new ApplicationException("DataSource property not set on layer '" + LayerName + "'"));

            // Get the transform
            var transform = new Matrix3x2(g.Transform.Elements);

            // Save state of the graphics object
            var gs = g.Save();

            // Create and prepare the render target
            var rt = RenderTargetFactory.Create(_d2d1Factory, g, map);

            // Set anti-alias mode and transform
            rt.AntialiasMode = AntialiasMode;
            rt.Transform = transform;

            if (Theme != null)
                RenderInternal(_d2d1Factory, rt, map, envelope, Theme);
            else
                RenderInternal(_d2d1Factory, rt, map, envelope);

            // Clean up the render target
            RenderTargetFactory.CleanUp(rt, g, map);
            
            // Restore the graphics object
            g.Restore(gs);

            // Invoke LayerRendered event
            OnLayerRendered(g);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:38,代码来源:SharpDXVectorLayer.cs

示例5: ConvertToByte

        /// <summary>
        /// Converts a <see cref="d.Image"/> to a byte array.
        /// </summary>
        /// <param name="image">The image to convert</param>
        /// <param name="format">The format in which to save the image</param>
        /// <returns>A byte array representing the image</returns>
        private byte[] ConvertToByte(d.Image image, ImageFormat format)
        {
            byte[] result;
            using (var stream = new System.IO.MemoryStream())
            {
                image.Save(stream, format);
                result = stream.ToArray();
            }

            return result;
        }
开发者ID:inuplan,项目名称:intranet,代码行数:17,代码来源:Handle.cs

示例6: BitmapToBitmapImage

        private BitmapImage BitmapToBitmapImage(Drawing.Bitmap bitmap)
        {
            BitmapImage resultImage;

            using (MemoryStream stream = new MemoryStream())
            {
                bitmap.Save(stream, ImageFormat.Bmp);

                stream.Position = 0;
                resultImage = new BitmapImage();
                resultImage.BeginInit();
                resultImage.StreamSource = stream;
                resultImage.CacheOption = BitmapCacheOption.OnLoad;
                resultImage.EndInit();
            }
            return resultImage;
        }
开发者ID:uzapy,项目名称:ch.bfh.bti7302.w2015.schneedetektion,代码行数:17,代码来源:OpenCVHelper.cs


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