- 1
- 0
- 约 2页
- 2017-06-08 发布于重庆
- 举报
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 Pic public partial class Form1 : Form public Form1 InitializeComponent ; private void button1_Click object sender, EventArgs e OpenFileDialog openDlg new OpenFileDialog ; openDlg.Multiselect false; if openDlg.ShowDialog this DialogResult.OK textBox1.Text openDlg.FileName; Bitmap bmp new Bitmap textBox1.Text ; pictureBox1.Image bmp; private void button2_Click object sender, EventArgs e int width pictureBox1.Width; int height pictureBox1.Height; Bitmap bmp Bitmap pictureBox1.Image; Bitmap newBMP new Bitmap width, height ; Color pixelColor1; Color pixelcolor2; int r, g, b; for int i 0; i width-1; i++ for int j 0; j height-1; j++ pixelColor1 bmp.GetPixel i, j ; pixelcolor2 bmp.GetPixel i + 1, j + 1 ; r Math.Abs pixelColor1.R - pixelcolor2.R + 128 ; g Math.Abs pixelColor1.G - pixelcolor2.G + 128 ; b Math.Abs pixelColor1.B - pixelcolor2.B + 128 ; if r 255 r 255; if r 0 r 0; if g 255 g 255; if g 0 g 0; if b 255 b 255; if b 0 b 0; newBMP.SetPixel i, j, Color.FromArgb r, g, b ; pictureBox2.Image newBMP; 效果预览:
原创力文档

文档评论(0)