




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
西北师范大学学生实验报告学院地环学院专业地理信息系统年级、班08级学号200875000431姓名王小燕同组者课程名称计算机图形学实验题目GDI+图形特技处理成绩一、实验目的:掌握在.net环境下对图形特技的处理方法。二、实验准备:学习在.net环境下读取图像文件、改变颜色等基本知识。三、实验内容:在.net环境中实现对图像的灰度化处理、柔化和锐化、底片滤镜、淡入淡出以及浮雕、油画和木刻等艺术效果。四、实验过程及步骤: (包括程序界面设计、控件属性说明、程序代码和程序运行四部分)程序代码 private void huidu_Click(object sender, EventArgs e) Graphics g = this.CreateGraphics(); g.Clear(Color.White); Bitmap image = new Bitmap(f:/王小燕/8.bmp); int width = image.Width - 1; int height = image.Height - 1; g.DrawImage(image, 0, 0); g.TranslateTransform(image.Width, 0); Bitmap image2 = image.Clone(new Rectangle(0, 0, image.Width, image.Height ),PixelFormat .DontCare); Bitmap image3 = image.Clone(new Rectangle(0, 0, image.Width, image.Height), PixelFormat.DontCare); Color color; for (int i = width; i = 0; i-) for (int j = height; j = 0; j-) color = image.GetPixel(i, j); int middle = (color.R + color.G + color.B) / 3; Color colorResult = Color.FromArgb(255, middle, middle, middle); image.SetPixel(i, j, colorResult); g.DrawImage(image, new Rectangle(0, 0, Width, Height); g.TranslateTransform(image.Width, 0); for (int i = width; i = 0; i-) for (int j = height; j = 0; j-) color = image2.GetPixel(i, j); int tmp = Math.Max(color.R, color.G); int maxcolor = Math.Max(tmp, color.B); Color colorResult = Color.FromArgb(255, maxcolor, maxcolor, maxcolor); image2.SetPixel(i, j, colorResult); g.DrawImage(image2, new Rectangle(0, 0, Width, Height); g.ResetTransform(); g.TranslateTransform(0, image.Height); for (int i = Width; i = 0; i-) for (int j = Height; j = 0; j-) color = image3.GetPixel(i, j); int R = (int)(0.3f * color.R); int G = (int)(0.59f * color.G); int B = (int)(0.11f * color.B); Color colorResult = Color.FromArgb(255, R, G, B); image3.SetPixel(i, j, colorResult); g.DrawImage(image3, new Rectangle(0, 0, width, height); g.TranslateTransform(image.Width, 0); for (int i = width; i 0; i-) for (int j = height; j 0; j-) color = image2.GetPixel(i, j); int R = color.R; int G = color.G; int B = color.B; if (R = 192) R = 255; if (R = 128) R = 4 * R - 510; bool yes; yes = false; if (G = 128 & (!yes) G = 255; yes = true; if (G = 192 & (!yes) G = 1022 - 4 * G; yes = true; if (G = 63 & (!yes) G = 254 - 4 * G; yes = true; if (G = 67 & (!yes) G = 4 * G - 257; if (B = 128) B = 0; if (B = 67 & B = 127) B = 510 - 4 * B; Color colorResult = Color.FromArgb(255, R, G, B); image2.SetPixel(i, j, colorResult); g.DrawImage(image2, new Rectangle(0, 0, width, height); private void rouhuaruihua_Click(object sender, EventArgs e) Graphics graphics = this.CreateGraphics(); graphics.Clear(Color.White); graphics.ScaleTransform(0.8f, 0.8f); Bitmap image = new Bitmap(f:/王小燕/8.bmp); int Width = image.Width; int Height = image.Height; Bitmap image2 = (Bitmap)image.Clone(); Color colorTemp; Color, color = new Color3, 3; graphics.DrawImage(image, new Rectangle(0, 0, Width, Height); for (int i = 1; i Width - 2; i+) for (int j = 1; j Height - 2; j+) color0, 0 = image.GetPixel(i - 1, j - 1); color0, 1 = image.GetPixel(i - 1, j); color0, 2 = image.GetPixel(i - 1, j + 1); color1, 0 = image.GetPixel(i, j - 1); color1, 1 = image.GetPixel(i, j); color1, 2 = image.GetPixel(i, j + 1); color2, 0 = image.GetPixel(i, j - 1); color2, 1 = image.GetPixel(i, j); color2, 2 = image.GetPixel(i + 1, j + 1); int rSum = 0; int gSum = 0; int bSum = 0; for (int n = 0; n 3; n+) for(int nn=0;nn3;nn+) rSum+= colorn,nn.R; gSum+= colorn,nn.G; bSum+= colorn,nn.B; colorTemp = Color.FromArgb(255, (int)(rSum / 9), (int)(bSum / 9), (int)(gSum / 9); image.SetPixel(i, j, colorTemp); graphics.DrawImage(image, new Rectangle(Width, 0, Width, Height); Color colorLeft,colornow; float dep = 0.550f; for (int i = 1; i Width - 1; i+) for (int j = 1; j Height - 1; j+) colornow = image2.GetPixel(i, j); colorLeft = image2.GetPixel(i - 1, j - 1); float r = colornow.R + (colornow.R - colornow.R * dep); r = Math.Min(255, Math.Max(0, r); float g = colornow.G + (colornow.G - colorLeft.G * dep); g = Math.Min(255, Math.Max(0, g); float b = colornow.B + (colornow.B - colorLeft.B * dep); b = Math.Min(255, Math.Max(0, b); colorTemp = Color.FromArgb(255, (int)r, (int)g, (int)b); image2.SetPixel(i, j, colorTemp); graphics.DrawImage(image2, new Rectangle(Width * 2, 0, Width, Height); private void danrudanchu_Click(object sender, EventArgs e) Graphics g = this.CreateGraphics(); g.Clear(Color.Blue); Bitmap bitmap = new Bitmap(f:/王小燕/8.bmp); int iWidth = bitmap.Width; int iHeight = bitmap.Height; float tem = new float 0.0f,0.0f,0.0f,0.0f,0.0f, new float 0.0f,0.0f,0.0f,0.0f,0.0f, new float 0.0f,0.0f,0.0f,0.0f,0.0f, new float 0.0f,0.0f,0.0f,1.0f,0.0f, new float 0.0f,0.0f,0.0f,0.0f,1.0f ; ColorMatrix colorMatrix = new ColorMatrix(tem); ImageAttributes imageAtt = new ImageAttributes(); for (float i = 0.0f; i = 0.0f; i -= 0.02f) colorMatrix.Matrix00 = i; colorMatrix.Matrix11 = i; colorMatrix.Matrix22 = i; colorMatrix.Matrix33 = i; imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); g.DrawImage(bitmap, new Rectangle(0, 0, iWidth, iHeight), 0, 0, iWidth, iHeight, GraphicsUnit.Pixel, imageAtt); private void lvjing_Click(object sender, EventArgs e) Graphics graphics = this.CreateGraphics(); graphics.Clear(Color.White); graphics.ScaleTransform(0.7f, 0.7f); Bitmap image = new Bitmap(f:/王小燕/8.bmp); int Width = image.Width; int Height = image.Height; Bitmap image2 = image.Clone(new Rectangle(0, 0, Width, Height), PixelFormat.DontCare); graphics.DrawImage(image, new Rectangle(0, 0, Width, Height); Color color, colorLeft; for (int i = Width - 1; i 0; i-) for (int j = Height - 1; j 0; j-) color = image.GetPixel(i, j); colorLeft = image.GetPixel(i - 1, j - 1); 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); image.SetPixel(i, j, colorResult); graphics.DrawImage(image, new Rectangle(Width + 10, 0, Width, Height); for (int i = 0; i Height - 1; i+) for (int j = 0; j Width - 1; j+) color = image2.GetPixel(j, i); colorLeft = image.GetPixel(j + 1, i + 1); 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); image.SetPixel(j, i, colorResult); graphics.DrawImage(image, new Rectangle(Width + 10, 0, Width, Height); private void fudiaohediaoke_Click(object sender, EventArgs e) Graphics graphics = this.CreateGraphics(); graphics.Clear(Color.White); graphics.ScaleTransform(0.5f, 0.5f); Bitmap image = new Bitmap(f:/王小燕/8.bmp); int Width = image.Width; int Height = image.Height; Color color,colorTemp; graphics.DrawImage(image, new Rectangle(0, 0, Width, Height); int tmp; for (int i = 0; i Width; i+) for (int j = 0; j = 128) tmp = 2
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年经济政策与行业风险分析试题及答案
- 网络管理员考试各类型训练试题及答案
- 软件系统测试核心概念解析试题及答案
- 计算机科学理论与实践结合试题及答案
- VB编程理论试题及答案
- 提升营收的多元化策略计划
- 吉林省松原市名校2025届数学七下期末监测模拟试题含解析
- 择业思考与决策计划
- 2025软考网络管理员提高试题及答案
- 仓库货物损耗控制措施计划
- 信贷业务法律风险防范
- 幼儿园艺术(美术)教育活动设计与实施 课件 模块4 设计与实施幼儿园美术欣赏活动
- 冷链物流司机岗位职责与工作流程介绍
- 2型糖尿病中西医结合诊疗指南(2025年)解读课件
- 浙江大学专职辅导员招聘真题2024
- 2022万能试验机验收规范
- 西部计划考试考题及答案
- 《低钾血症病人护理》课件
- 消防水池防水合同
- 2025年供港活牛供宰与屠宰设备采购合同
- 2024绿城地产代建项目合作协议范本9篇
评论
0/150
提交评论