// </snippet4> // Snippet for: M:System.Drawing.Imaging.ImageAttributes.SetNoOp // <snippet5> private void SetNoOpExample(PaintEventArgs e) { // Create an Image object from the file Camera.jpg. Image myImage = Image.FromFile("Camera.jpg"); // Create an ImageAttributes object, and set the gamma to 0.25. ImageAttributes imageAttr = new ImageAttributes(); imageAttr.SetGamma(0.25f); // Draw the image with gamma set to 0.25. Rectangle rect1 = new Rectangle(20, 20, 200, 200); e.Graphics.DrawImage(myImage, rect1, 0, 0, 200, 200, GraphicsUnit.Pixel, imageAttr); // Call the ImageAttributes NoOp method. imageAttr.SetNoOp(); // Draw the image after NoOp is set, so the default gamma value // of 1.0 will be used. Rectangle rect2 = new Rectangle(250, 20, 200, 200); e.Graphics.DrawImage(myImage, rect2, 0, 0, 200, 200, GraphicsUnit.Pixel, imageAttr); }
private void SetNoOp_Click(object sender, System.EventArgs e) { // Create a Graphics object Graphics g = this.CreateGraphics(); g.Clear(this.BackColor); // Create two colors Color lClr = Color.FromArgb(245, 0, 0); Color uClr = Color.FromArgb(255, 0, 0); // Create ImageAttributes object ImageAttributes ImgAttr = new ImageAttributes(); // Set ColorKey ImgAttr.SetColorKey(lClr, uClr, ColorAdjustType.Default); // Set gamma ImgAttr.SetGamma(2.0f, ColorAdjustType.Default); // Set NoOp ImgAttr.SetNoOp(ColorAdjustType.Default); // Create an Image object Image curImage = Image.FromFile("dnWatcher.gif"); // Draw Image Rectangle rect = new Rectangle(0, 0, 400, 400); g.DrawImage(curImage, rect, 0, 0, 400, 400, GraphicsUnit.Pixel, ImgAttr); // Dispose g.Dispose(); }