本系列第一篇,實作最基礎的「底片效果」:RGB 各通道取反 (255 - value),產生底片負片視覺。
(x,y),讀取 RGB。R' = 255-R, G' = 255-G, B' = 255-B。
private void btnNegative_Click(object sender, EventArgs e)
{
try
{
int w = pictureBox1.Image.Width, h = pictureBox1.Image.Height;
using (var newBmp = new Bitmap(w, h))
using (var oldBmp = (Bitmap)pictureBox1.Image)
{
for (int x = 1; x < w; x++)
for (int y = 1; y < h; y++)
{
Color p = oldBmp.GetPixel(x, y);
int r = 255 - p.R;
int g = 255 - p.G;
int b = 255 - p.B;
newBmp.SetPixel(x, y, Color.FromArgb(r, g, b));
}
pictureBox1.Image = newBmp;
}
}
catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); }
}

原始圖片:
本系列共 12 篇,涵蓋:底片、浮雕、黑白、柔化、銳化、霧化、光照、百葉窗、馬賽克、油畫、積木。核心技術:Bitmap.GetPixel/SetPixel、Graphics.DrawImage、卷積核、隨機取樣、距離衰減。後續將展示動態特效 (分塊合成、四周擴散、上下對接)。
底片效果是像素級運算的 Hello World。掌握 Bitmap、Color、Graphics 基礎操作,即可進入豐富的圖像處理世界。