本文整理汇总了C#中System.Drawing类的典型用法代码示例。如果您正苦于以下问题:C# Drawing类的具体用法?C# Drawing怎么用?C# Drawing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Drawing类属于System命名空间,在下文中一共展示了Drawing类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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;
}
示例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;
}
示例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))
{
}
示例6: RenderableText
public RenderableText(string pmText, Sdx.Font pmFont, Point pmPosition, float pmWrapSize)
{
text= pmText;
font= pmFont;
position= pmPosition;
wrapSize= pmWrapSize;
}
示例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);
}
示例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);
}
示例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
}
示例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
};
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}