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


C# System.Drawing类代码示例

本文整理汇总了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);
 }
开发者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


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