[C#][VB.NET]反轉圖片顏色
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /white-space: pre;/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]> C#using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms; namespace WindowsFormsApplication1 { //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| //Author: Larry Nung //Date: 2009/6/2 //File: //Memo: //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| /// <summary> /// /// </summary> public partial class Form1 : Form { public Form1() { InitializeComponent(); } // //Author: Larry Nung //Date: 2009/6/2 //Purpose: //Memo: // /// <summary> /// Handles the Click event of the button1 control. /// </summary> /// <param name=“sender”>The source of the event.</param> /// <param name=“e”>The <see cref=“System.EventArgs”/> instance containing the event data.</param> private void button1_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { pictureBox1.Image = GetInvertBitmap(openFileDialog1.FileName); } } // //Author: Larry Nung //Date: 2009/6/2 //Purpose: //Memo: // /// <summary> /// Gets the invert bitmap. /// </summary> /// <param name=“file”>The file.</param> /// <returns></returns> private Bitmap GetInvertBitmap(string file) { Bitmap bmp = new Bitmap(file); for (int x = 0; x < bmp.Width; x++) { for (int y = 0; y < bmp.Height; y++) { Color color = bmp.GetPixel(x, y); bmp.SetPixel(x, y, Color.FromArgb(255 - color.R, 255 - color.G, 255 - color.B)); } } return bmp; } } }<![CDATA[
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /white-space: pre;/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }]]> 執行結果: