本文整理汇总了C#中System.Drawing类的典型用法代码示例。如果您正苦于以下问题:C# Drawing类的具体用法?C# Drawing怎么用?C# Drawing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Drawing类属于System命名空间,在下文中一共展示了Drawing类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BitmapBuffer
/// <summary>
/// Initializes the BitmapBuffer from a System.Drawing.Bitmap
/// </summary>
public BitmapBuffer(sd.Bitmap bitmap, BitmapLoadOptions options)
{
if (options.AllowWrap && bitmap.PixelFormat == PixelFormat.Format32bppArgb)
{
Width = bitmap.Width;
Height = bitmap.Height;
WrappedBitmap = bitmap;
}
else LoadInternal(null, bitmap, options);
}
开发者ID:cas1993per,项目名称:bizhawk,代码行数:13,代码来源:BitmapBuffer.cs
示例2: GetMIMEType
/// <summary>
/// Get the W3C standard MIME type for this image
/// </summary>
/// <param name="image">Image to parse</param>
/// <returns>Image MIME type or 'image/unknown' if not found</returns>
public static string GetMIMEType(SysDrawing.Image image)
{
// [Citation("200803142256", AcquiredDate = "2008-03-14", Author = "Chris Hynes", Source = "http://chrishynes.net/blog/archive/2008/01/17/Get-the-MIME-type-of-a-System.Drawing-Image.aspx", SourceDate = "2008-01-17")]
foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageDecoders())
{
if (codec.FormatID == image.RawFormat.Guid)
return codec.MimeType;
}
return Mime.Map[""].MediaType;
}
开发者ID:drio4321,项目名称:ScrimpNet.Core,代码行数:15,代码来源:Mime.cs
示例3: SysTrayIcon
/// <summary>
/// Constructs a system tray icon
/// </summary>
/// <param name="mainForm"></param>
/// <param name="icon"></param>
public SysTrayIcon(MainForm mainForm, Drawing.Icon icon)
{
this.mainForm = mainForm;
this.notify = new WinForms.NotifyIcon();
this.notify.Text = "NBM";
this.notify.Icon = icon;
this.notify.Click += new EventHandler(OnSysTrayClick);
this.notify.ContextMenu = new SysTrayContextMenu(mainForm);
this.notify.Visible = true;
}
开发者ID:peteward44,项目名称:nbm-messenger,代码行数:16,代码来源:SysTrayIcon.cs
示例4: DrawIcon
private static Drawing.Icon DrawIcon(Drawing.Brush fillBrush, string message, int dimension)
{
Drawing.Icon oIcon = null;
Drawing.Bitmap bm = new Drawing.Bitmap(dimension, dimension);
Drawing.Graphics g = Drawing.Graphics.FromImage((Drawing.Image)bm);
g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias;
Drawing.Font oFont = new Drawing.Font("Arial", 30, Drawing.FontStyle.Bold, Drawing.GraphicsUnit.Pixel);
g.FillRectangle(fillBrush, new Drawing.Rectangle(0, 0, bm.Width, bm.Height));
g.DrawString(message, oFont, new Drawing.SolidBrush(Drawing.Color.Black), 2, 0);
oIcon = Drawing.Icon.FromHandle(bm.GetHicon());
oFont.Dispose();
g.Dispose();
bm.Dispose();
return oIcon;
}
开发者ID:AndyAn,项目名称:Miiror,代码行数:16,代码来源:IconManager.cs
示例5: FormXObject
/**
<summary>Creates a new form within the specified document context.</summary>
<param name="context">Document where to place this form.</param>
<param name="size">Form size.</param>
*/
public FormXObject(
Document context,
drawing::SizeF size
)
: this(context, new drawing::RectangleF(new drawing::PointF(0, 0), size))
{
}
开发者ID:n9,项目名称:pdfclown,代码行数:12,代码来源:FormXObject.cs
示例6: RenderableText
public RenderableText(string pmText, Sdx.Font pmFont, Point pmPosition, float pmWrapSize)
{
text= pmText;
font= pmFont;
position= pmPosition;
wrapSize= pmWrapSize;
}
开发者ID:pgonzbecer,项目名称:apis-bundle,代码行数:7,代码来源:RenderableText.cs
示例7: CleanUp
public void CleanUp(D2D1.RenderTarget target, GDI.Graphics g, Map map)
{
target.EndDraw();
using (var sc = TakeScreenshotGdi(map.Size))
g.DrawImage(sc, new GDI.Point(0, 0));
target.Dispose();
//Monitor.Exit(_syncRoot);
}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:10,代码来源:Texture2DRenderTargetFactory.cs
示例8: Aiguille2
private static void Aiguille2(Graphics g, double pc, D.Brush b, double r, float pw, double x0, double y0)
{
double x1, y1, x2, y2;
double a = GetAFromPc(pc);
GetXY2(a, r, x0, y0, out x1, out y1);
GetXY2(a+Math.PI, r/5.0, x0, y0, out x2, out y2);
g.DrawLine(new D.Pen(b, pw), (float)x1, (float)y1, (float)x2, (float)y2);
}
开发者ID:bnogent,项目名称:time,代码行数:11,代码来源:MainWindow.xaml.cs
示例9: 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
示例10: ToScaledRectangleF
public Gdi.RectangleF ToScaledRectangleF(Gdi.Size screenBounds, Vector3D position, double radius)
{
var size = (float)(2 * radius);
return new Gdi.RectangleF
{
X = (float)(position.X * screenBounds.Width - radius),
Y = (float)(position.Y * screenBounds.Height - radius),
Width = size,
Height = size
};
}
开发者ID:techx,项目名称:old-techfair-kinect-booth,代码行数:11,代码来源:GdiParticleComponentRenderer.cs
示例11: CalculateBoxJoints
private Dictionary<JointType, Vector3D> CalculateBoxJoints(Gdi.RectangleF skeletonBox)
{
return base.SkeletonComponent.CurrentSkeleton.Select(kvp =>
Tuple.Create(
kvp.Key,
new Vector3D(
kvp.Value.LocationScreenPercent.X * skeletonBox.Width + skeletonBox.X,
(1 - kvp.Value.LocationScreenPercent.Y) * skeletonBox.Height + skeletonBox.Y, //y is flipped
0)))
.ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2);
}
开发者ID:techx,项目名称:old-techfair-kinect-booth,代码行数:11,代码来源:GdiSkeletonComponentRenderer.cs
示例12: Resize
public static NSImage Resize(this NSImage image, sd.Size newsize, ImageInterpolation interpolation = ImageInterpolation.Default)
{
var newimage = new NSImage(newsize);
var newrep = new NSBitmapImageRep(IntPtr.Zero, newsize.Width, newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * newsize.Width, 32);
newimage.AddRepresentation(newrep);
var graphics = NSGraphicsContext.FromBitmap(newrep);
NSGraphicsContext.GlobalSaveGraphicsState();
NSGraphicsContext.CurrentContext = graphics;
graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG();
image.DrawInRect(new sd.RectangleF(sd.PointF.Empty, newimage.Size), new sd.RectangleF(sd.PointF.Empty, image.Size), NSCompositingOperation.SourceOver, 1f);
NSGraphicsContext.GlobalRestoreGraphicsState();
return newimage;
}
开发者ID:Exe0,项目名称:Eto,代码行数:14,代码来源:NSImageExtensions.cs
示例13: EncodeGdi
public byte[] EncodeGdi(SD.Bitmap image, float bitrate = WsqCodec.Constants.DefaultBitrate, bool autoConvertToGrayscale = true)
{
if (image == null) throw new ArgumentNullException("image");
RawImageData data = null;
if (autoConvertToGrayscale)
{
using (var source = Conversions.To8bppBitmap(image))
data = Conversions.GdiImageToImageInfo(source);
}
else data = Conversions.GdiImageToImageInfo(image);
return WsqCodec.Encode(data, bitrate, Comment);
}
开发者ID:eliudiaz,项目名称:Delta.Imaging,代码行数:14,代码来源:WsqEncoder.cs
示例14: StartVideo
/// <summary>
/// Function to start showing video
/// </summary>
/// <param name="videoHandle">Video handle</param>
/// <param name="videoRegion">Region where to show video</param>
/// <param name="videoHorizontalResolution">Video horizontal resolution</param>
/// <param name="videoVerticalResolution">Video vertical resolution</param>
public void StartVideo(IntPtr videoHandle, SD.Rectangle videoRegion, int videoHorizontalResolution, int videoVerticalResolution)
{
//// Creates instance of Web cam class of DirectShow
this.webCam = new Webcam(videoHandle);
var selectedCamera = this.SelectCamera();
if (selectedCamera >= 0)
{
var deviceName = this.webCam.StartVideo(videoHandle, videoRegion, videoHorizontalResolution, videoVerticalResolution, selectedCamera);
CameraStatus.Status = string.IsNullOrEmpty(deviceName) ? CameraAvailability.Busy : CameraAvailability.Available;
}
else
{
CameraStatus.Status = CameraAvailability.NotAvailable;
}
}
开发者ID:JaipurAnkita,项目名称:mastercode,代码行数:22,代码来源:CameraUtility.cs
示例15: Texture
public Texture(Sdx.Bitmap bmp)
{
// Variables
Sdx.Imaging.BitmapData bmpdata= bmp.LockBits(new Sdx.Rectangle(0, 0, bmp.Width, bmp.Height), Sdx.Imaging.ImageLockMode.ReadOnly, Sdx.Imaging.PixelFormat.Format32bppArgb);
int tid= GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, tid);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp.Width, bmp.Height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, bmpdata.Scan0);
bmp.UnlockBits(bmpdata);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int) TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int) TextureMagFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int) TextureWrapMode.Repeat);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int) TextureWrapMode.Repeat);
ID= tid;
bitmap= bmp;
}
开发者ID:pgonzbecer,项目名称:GDToolkit,代码行数:18,代码来源:Texture.cs
示例16: AdjustPictureBoxSize
/// <summary>
/// Function to calculate new height of the image container as per dimension of the picture
/// </summary>
/// <param name="pictureSize">Captured picture size</param>
/// <param name="imageContainer">Image container whose size is to be changed</param>
public static void AdjustPictureBoxSize(SD.Size pictureSize, Image imageContainer)
{
if (imageContainer != null)
{
if (pictureSize.Width > imageContainer.Width)
{
// Calculates and set new height of image container as per photoSize
imageContainer.Height = (imageContainer.Width * pictureSize.Height) / pictureSize.Width;
imageContainer.Stretch = Stretch.Uniform;
}
else
{
imageContainer.Width = imageContainer.Width;
imageContainer.Height = pictureSize.Height;
imageContainer.Stretch = Stretch.None;
}
}
}
开发者ID:JaipurAnkita,项目名称:mastercode,代码行数:24,代码来源:PictureHelper.cs
示例17: Screen
public Screen(
Page page,
drawing::RectangleF box,
String text,
String mediaPath,
String mimeType
)
: this(page, box, text,
new MediaRendition(
new MediaClipData(
FileSpecification.Get(
EmbeddedFile.Get(page.Document, mediaPath),
System.IO.Path.GetFileName(mediaPath)
),
mimeType
)
))
{
}
开发者ID:n9,项目名称:pdfclown,代码行数:19,代码来源:Screen.cs
示例18: ToBitmapSource
public static BitmapSource ToBitmapSource(SD.Bitmap source)
{
var hBitmap = source.GetHbitmap();
try
{
return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
hBitmap,
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
}
catch (Win32Exception)
{
return null;
}
finally
{
DeleteObject(hBitmap);
}
}
开发者ID:zerkms,项目名称:shary,代码行数:21,代码来源:Fullscreen.xaml.cs
示例19: 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
示例20: Create
public D2D1.RenderTarget Create(D2D1.Factory factory, GDI.Graphics g, Map map)
{
//Monitor.Enter(_syncRoot);
// Dispose the _renderTexture if it is instantiated and not of the required size
CheckTexture(ref _renderTexture, map.Size);
// Create a new render texture if one is needed
if (_renderTexture == null)
{
_renderTexture = CreateRenderTargetTexture(_d3d11Device, map.Size.Width, map.Size.Height);
}
// Get the surface
var surface = _renderTexture.QueryInterface<DXGI.Surface>();
var res = new D2D1.RenderTarget(factory, surface, new D2D1.RenderTargetProperties(
D2D1.RenderTargetType.Hardware, new D2D1.PixelFormat(DXGI.Format.B8G8R8A8_UNorm, D2D1.AlphaMode.Premultiplied),
g.DpiX, g.DpiY, D2D1.RenderTargetUsage.None, D2D1.FeatureLevel.Level_DEFAULT));
res.BeginDraw();
return res;
}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:24,代码来源:Texture2DRenderTargetFactory.cs
注:本文中的System.Drawing类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论