本文整理汇总了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
}
示例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;
}
示例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++;
}
示例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);
}
示例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;
}
示例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;
}