using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Imaging;
namespace EmbossColander
{
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(350,200);
this.Text = "Form1";
}
#endregion
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
Graphics graphics = e.Graphics;
graphics.Clear(Color.White);
graphics.ScaleTransform(0.7f,0.7f);
Bitmap image = new Bitmap("dog.bmp");
int Width = image.Width;
int Height = image.Height;
//image2:进行雕刻处理
Bitmap image2 = image.Clone(new Rectangle(0,0,Width,Height),PixelFormat.DontCare );
//绘制原图
graphics.DrawImage(
image, new Rectangle(0, 0, Width, Height));
Color color, colorTemp,colorLeft;
//进行图片的浮雕处理
//依次访问每个像素的RGB值
for(int i=Width-1; i>0;i--)
{
for( int j=Height-1; j>0;j--)
{
//获取相邻两个像素的R、G、B值
color =image.GetPixel(i, j);
colorLeft=image.GetPixel(i-1, j-1);
//计算与左上角像素的RGB分量之差
//67:控制图片的最低灰度,128:常量,更改这两个值会得到不同的效果
int r = Math.Max(67,Math.Min(255,
Math.Abs(color.R-colorLeft.R+128)));
int g = Math.Max(67,Math.Min(255,
Math.Abs(color.G-colorLeft.G+128)));
int b = Math.Max(67,Math.Min(255,
Math.Abs(color.B-colorLeft.B+128)));
Color colorResult=Color.FromArgb(255,r,g,b);
//将计算后的RGB值回写到位图
image.SetPixel(i, j,colorResult);
}
//绘制浮雕图
graphics.DrawImage(
image, new Rectangle(Width+10, 0, Width, Height));
}
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有