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


C# Bitmap.Watermark方法代码示例

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


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

示例1: Process

 /// <summary>
 /// Runs the motion detection algorithm
 /// </summary>
 /// <param name="NewImage">The "new" frame</param>
 /// <param name="OldImage">The "old" frame</param>
 /// <param name="Threshold">The threshold used to detect changes in the image</param>
 /// <param name="DetectionColor">Color to display changes in the images as</param>
 /// <returns>A bitmap indicating where changes between frames have occurred overlayed on top of the new image.</returns>
 public static Bitmap Process(Bitmap NewImage, Bitmap OldImage, int Threshold, Color DetectionColor)
 {
     if (NewImage == null)
         throw new ArgumentNullException("NewImage");
     if (OldImage == null)
         throw new ArgumentNullException("OldImage");
     if (DetectionColor == null)
         throw new ArgumentNullException("DetectionColor");
     using (Bitmap NewImage1 = NewImage.BlackAndWhite())
     {
         using (Bitmap OldImage1 = OldImage.BlackAndWhite())
         {
             using (Bitmap NewImage2 = NewImage1.SNNBlur(5))
             {
                 using (Bitmap OldImage2 = OldImage1.SNNBlur(5))
                 {
                     using (Bitmap OutputImage = new Bitmap(NewImage2, NewImage2.Width, NewImage2.Height))
                     {
                         using (Bitmap Overlay = new Bitmap(NewImage, NewImage.Width, NewImage.Height))
                         {
                             BitmapData NewImage2Data = NewImage2.LockImage();
                             int NewImage2PixelSize = NewImage2Data.GetPixelSize();
                             BitmapData OldImage2Data = OldImage2.LockImage();
                             int OldImage2PixelSize = OldImage2Data.GetPixelSize();
                             BitmapData OverlayData = Overlay.LockImage();
                             int OverlayPixelSize = OverlayData.GetPixelSize();
                             for (int x = 0; x < OutputImage.Width; ++x)
                             {
                                 for (int y = 0; y < OutputImage.Height; ++y)
                                 {
                                     Color NewPixel = NewImage2Data.GetPixel(x, y, NewImage2PixelSize);
                                     Color OldPixel = OldImage2Data.GetPixel(x, y, OldImage2PixelSize);
                                     if (System.Math.Pow((double)(NewPixel.R - OldPixel.R), 2.0) > Threshold)
                                     {
                                         OverlayData.SetPixel(x, y, Color.FromArgb(100, 0, 100), OverlayPixelSize);
                                     }
                                     else
                                     {
                                         OverlayData.SetPixel(x, y, Color.FromArgb(200, 0, 200), OverlayPixelSize);
                                     }
                                 }
                             }
                             Overlay.UnlockImage(OverlayData);
                             NewImage2.UnlockImage(NewImage2Data);
                             OldImage2.UnlockImage(OldImage2Data);
                             using (Bitmap Overlay2 = Overlay.EdgeDetection(25, DetectionColor))
                             {
                                 BitmapData Overlay2Data = Overlay2.LockImage();
                                 int Overlay2PixelSize = Overlay2Data.GetPixelSize();
                                 for (int x = 0; x < OutputImage.Width; ++x)
                                 {
                                     for (int y = 0; y < OutputImage.Height; ++y)
                                     {
                                         Color Pixel1 = Overlay2Data.GetPixel(x, y, Overlay2PixelSize);
                                         if (Pixel1.R != DetectionColor.R || Pixel1.G != DetectionColor.G || Pixel1.B != DetectionColor.B)
                                         {
                                             Overlay2Data.SetPixel(x, y, Color.FromArgb(200, 0, 200), Overlay2PixelSize);
                                         }
                                     }
                                 }
                                 Overlay2.UnlockImage(Overlay2Data);
                                 return OutputImage.Watermark(Overlay2, 1.0f, 0, 0, Color.FromArgb(200, 0, 200));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:JKLFA,项目名称:Craig-s-Utility-Library,代码行数:78,代码来源:MotionDetection.cs

示例2: Watermark

 public void Watermark()
 {
     using (Bitmap TestObject = new Bitmap(@"..\..\Data\Image\Lenna.jpg"))
     {
         using (Bitmap TestObject2 = new Bitmap(@"..\..\Data\Image\Image2.jpg"))
         {
             using (Bitmap Image = Assert.Do<Bitmap>(() => TestObject.Watermark(TestObject2, 0.5f, 0, 0, Color.Black, @".\Testing\LennaWatermark.jpg")))
             {
                 Assert.NotNull(Image);
             }
         }
     }
 }
开发者ID:gwilkinson,项目名称:Craig-s-Utility-Library,代码行数:13,代码来源:BitmapExtensions.cs

示例3: MotionDetection

 /// <summary>
 /// Runs a simplistic motion detection algorithm
 /// </summary>
 /// <param name="NewImage">The "new" frame</param>
 /// <param name="OldImage">The "old" frame</param>
 /// <param name="Threshold">The threshold used to detect changes in the image</param>
 /// <param name="DetectionColor">Color to display changes in the images as</param>
 /// <returns>A bitmap indicating where changes between frames have occurred overlayed on top of the new image.</returns>
 public static Bitmap MotionDetection(this Bitmap NewImage, Bitmap OldImage, int Threshold, Color DetectionColor)
 {
     NewImage.ThrowIfNull("NewImage");
     OldImage.ThrowIfNull("OldImage");
     DetectionColor.ThrowIfNull("DetectionColor");
     using (Bitmap NewImage1 = NewImage.BlackAndWhite())
     {
         using (Bitmap OldImage1 = OldImage.BlackAndWhite())
         {
             using (Bitmap NewImage2 = NewImage1.SNNBlur(5))
             {
                 using (Bitmap OldImage2 = OldImage1.SNNBlur(5))
                 {
                     using (Bitmap OutputImage = new Bitmap(NewImage2, NewImage2.Width, NewImage2.Height))
                     {
                         using (Bitmap Overlay = new Bitmap(NewImage, NewImage.Width, NewImage.Height))
                         {
                             BitmapData NewImage2Data = NewImage2.LockImage();
                             int NewImage2PixelSize = NewImage2Data.GetPixelSize();
                             BitmapData OldImage2Data = OldImage2.LockImage();
                             int OldImage2PixelSize = OldImage2Data.GetPixelSize();
                             BitmapData OverlayData = Overlay.LockImage();
                             int OverlayPixelSize = OverlayData.GetPixelSize();
                             int Width = OutputImage.Width;
                             int Height = OutputImage.Height;
                             Parallel.For(0, Width, x =>
                             {
                                 for (int y = 0; y < Height; ++y)
                                 {
                                     Color NewPixel = NewImage2Data.GetPixel(x, y, NewImage2PixelSize);
                                     Color OldPixel = OldImage2Data.GetPixel(x, y, OldImage2PixelSize);
                                     if (System.Math.Pow((double)(NewPixel.R - OldPixel.R), 2.0) > Threshold)
                                     {
                                         OverlayData.SetPixel(x, y, Color.FromArgb(100, 0, 100), OverlayPixelSize);
                                     }
                                     else
                                     {
                                         OverlayData.SetPixel(x, y, Color.FromArgb(200, 0, 200), OverlayPixelSize);
                                     }
                                 }
                             });
                             Overlay.UnlockImage(OverlayData);
                             NewImage2.UnlockImage(NewImage2Data);
                             OldImage2.UnlockImage(OldImage2Data);
                             using (Bitmap Overlay2 = Overlay.EdgeDetection(25, DetectionColor))
                             {
                                 BitmapData Overlay2Data = Overlay2.LockImage();
                                 int Overlay2PixelSize = Overlay2Data.GetPixelSize();
                                 Width = OutputImage.Width;
                                 Height = OutputImage.Height;
                                 Parallel.For(0, Width, x =>
                                 {
                                     for (int y = 0; y < Height; ++y)
                                     {
                                         Color Pixel1 = Overlay2Data.GetPixel(x, y, Overlay2PixelSize);
                                         if (Pixel1.R != DetectionColor.R || Pixel1.G != DetectionColor.G || Pixel1.B != DetectionColor.B)
                                         {
                                             Overlay2Data.SetPixel(x, y, Color.FromArgb(200, 0, 200), Overlay2PixelSize);
                                         }
                                     }
                                 });
                                 Overlay2.UnlockImage(Overlay2Data);
                                 return OutputImage.Watermark(Overlay2, 1.0f, 0, 0, Color.FromArgb(200, 0, 200));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:Adilson,项目名称:Craig-s-Utility-Library,代码行数:79,代码来源:BitmapExtensions.cs


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