C# graphicspath 翻转
来源:互联网 发布:江大网络教育主页 编辑:程序博客网 时间:2024/05/01 08:34
C#中GraphicsPath旋转问题(发现网上与此相关的资料很少,我是从一个英文网站上找到的方法,具体原理还不是很明白,写出来大家分享一下)
准备:新建一窗体,添加一个PictureBox和一个btn
功能:点击btn实现图像翻转
备注:我用的是png格式的图
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace pathflip
{
public partial class Form1 : Form
{
private GraphicsPath path;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Image image = this.pictureBox1.Image;
image.RotateFlip(RotateFlipType.Rotate180FlipY);
this.pictureBox1.Image = image;
Matrix matrix = new Matrix(-1, 0, 0, 1, image.Width, 0);
this.path.Transform(matrix);
this.pictureBox1.Region = new Region(this.path);
}
private void Form1_Load(object sender, EventArgs e)
{
Bitmap bmp = (Bitmap)this.pictureBox1.Image;
this.path = this.CalculateGrahicsPath(bmp);
this.pictureBox1.Region = new Region(this.path);
}
private GraphicsPath CalculateGrahicsPath(Bitmap bitmap)//Region设定前,Graphicpaths获取函数
{
int iWidth = bitmap.Width;
int iHeight = bitmap.Height;
GraphicsPath graphicpath = new GraphicsPath();
System.Drawing.Color color;
for (int row = 0; row < iHeight; row++)
for (int wid = 0; wid < iWidth; wid++)
{
color = bitmap.GetPixel(wid, row);
//if (255 == color.A)
if (255 == color.A)
graphicpath.AddRectangle(new Rectangle(wid, row, 1, 1));
}
return graphicpath;
}
}
}
- C# graphicspath 翻转
- C# GraphicsPath属性、方法
- c#中GraphicsPath的Flatten方法
- c#中GraphicsPath的Widen方法
- c#中GraphicsPath的Warp方法
- c#中GraphicsPath的AddString方法
- 生成GraphicsPath
- graphicspath创建
- GraphicsPath对象
- C#实现图片翻转
- C#翻转字符串
- C# 图象的翻转(转)
- c#图像旋转和翻转
- 取得GraphicsPath的源码
- 笔记9:GraphicsPath对象
- gdi+ 的 graphicspath
- GDI+ 1.2 GraphicsPath
- GraphicsPath.AddArc解析
- java中的ClassLoader类加载器
- jsp中的日期问题及其它
- url路径参数带中文的乱码解决(前后台均为UTF-8)
- JSP 语法详解
- VB.NET 之 Chr 函数
- C# graphicspath 翻转
- poj 2817
- 如何配置iis?
- C语言预处理器
- 去除iPhone icon的光晕效果
- 单向加密算法
- Oracle 10.2.0.1 升级到 10.2.0.4
- Oracle创建删除的外键脚本
- java对象占内存大小