Bitmap newpic;
Bitmap oldpic;
for (int y = 1; y < oldpic.Height; y++)
{
for (int x = 1; x < oldpic.Width; x++)
{
newColor = oldpic.GetPixel(oldpic.Width - x , x);
newpic.SetPixel(x, y, newColor);
}
picShow.Image = newpic;这样貌似不行~!请高手指点
Bitmap oldpic;
for (int y = 1; y < oldpic.Height; y++)
{
for (int x = 1; x < oldpic.Width; x++)
{
newColor = oldpic.GetPixel(oldpic.Width - x , x);
newpic.SetPixel(x, y, newColor);
}
picShow.Image = newpic;这样貌似不行~!请高手指点
解决方案 »
- 求大家进来看看吧!----世界未解之谜2
- C#如何从数据库里读取iamge类型的数据,让其显示在pictureBox里
- 謝謝gomoku與kksxj提供的的資料
- 求InstallShield11 注册机/注册号
- 请问哪位知道留言板群发是怎么实现的呀?
- 求Mono编译器中文说明书...多谢了
- 两个button实现翻页
- Compare("world","WORLd",false) 为什么返回-1
- 一个端口的问题
- 噢,请问cd-key在vs.net beta2光盘的什么地方啊(别说安装时有)
- 谁知道在ADO.NET Entity Framework 外键为什么不能映射到实体属性上?
- (急切求助)C++版视频切割修改成C#版。。。
string filePath =@"C:\a.jpg";
using (Bitmap bm = new Bitmap(500,500))
{
using (Graphics g = Graphics.FromImage(bm))
{
g.Clear(Color.Wheat);
g.TranslateTransform(0, 0, MatrixOrder.Prepend);
g.RotateTransform(45);
FontFamily ff = new FontFamily("宋体");
Font f =new Font(ff,10);
Brush b = new SolidBrush(Color.Black);
StringFormat sf = new StringFormat();
g.DrawString("", f, b, new PointF(10, 10), sf);
g.DrawString("", f, b, new PointF(10, 10 + 30 + 10), sf);
}
bm.Save(filePath, ImageFormat.Jpeg);
} http://topic.csdn.net/u/20090420/00/4042e404-e802-45f7-8b25-c7fbc5a81c76.html
/// method to rotate an image either clockwise or counter-clockwise
/// </summary>
/// <param name="img">the image to be rotated</param>
/// <param name="rotationAngle">the angle (in degrees).
/// NOTE:
/// Positive values will rotate clockwise
/// negative values will rotate counter-clockwise
/// </param>
/// <returns></returns>
public static Image RotateImage(Image img, float rotationAngle)
{
//create an empty Bitmap image
Bitmap bmp = new Bitmap(img.Width, img.Height);
//turn the Bitmap into a Graphics object
Graphics gfx = Graphics.FromImage(bmp);
//now we set the rotation point to the center of our image
gfx.TranslateTransform((float)bmp.Width / 2, (float)bmp.Height / 2);
//now rotate the image
gfx.RotateTransform(rotationAngle);
gfx.TranslateTransform(-(float)bmp.Width / 2, -(float)bmp.Height / 2);
//set the InterpolationMode to HighQualityBicubic so to ensure a high
//quality image once it is transformed to the specified size
gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
//now draw our new image onto the graphics object
gfx.DrawImage(img, new Point(0, 0));
//dispose of our Graphics object
gfx.Dispose();
//return the image
return bmp;
}
那么麻烦的!
Image img = Image.FromFile("C:\\1.jpeg");
img.RotateFlip(RotateFlipType.Rotate90FlipX);
img.Save("C:\\2.jpeg");
System.Drawing.RotateFlipType枚举
// 摘要:
// 指定图像的旋转方向和用于翻转图像的轴。
public enum RotateFlipType
{
// 摘要:
// 指定后接水平翻转和垂直翻转的 180 度旋转。
Rotate180FlipXY = 0,
//
// 摘要:
// 指定不进行旋转和翻转。
RotateNoneFlipNone = 0,
//
// 摘要:
// 指定后接水平翻转和垂直翻转的 270 度旋转。
Rotate270FlipXY = 1,
//
// 摘要:
// 指定不进行翻转的 90 度旋转。
Rotate90FlipNone = 1,
//
// 摘要:
// 指定不进行翻转的 180 度旋转。
Rotate180FlipNone = 2,
//
// 摘要:
// 指定没有后跟水平和垂直翻转的旋转。
RotateNoneFlipXY = 2,
//
// 摘要:
// 指定不进行翻转的 270 度旋转。
Rotate270FlipNone = 3,
//
// 摘要:
// 指定后接水平翻转和垂直翻转的 90 度旋转。
Rotate90FlipXY = 3,
//
// 摘要:
// 指定后接垂直翻转的 180 度旋转。
Rotate180FlipY = 4,
//
// 摘要:
// 指定没有后跟水平翻转的旋转。
RotateNoneFlipX = 4,
//
// 摘要:
// 指定后接水平翻转的 90 度旋转。
Rotate90FlipX = 5,
//
// 摘要:
// 指定后接垂直翻转的 270 度旋转。
Rotate270FlipY = 5,
//
// 摘要:
// 指定没有后跟垂直翻转的旋转。
RotateNoneFlipY = 6,
//
// 摘要:
// 指定后接水平翻转的 180 度旋转。
Rotate180FlipX = 6,
//
// 摘要:
// 指定后接垂直翻转的 90 度旋转。
Rotate90FlipY = 7,
//
// 摘要:
// 指定后接水平翻转的 270 度旋转。
Rotate270FlipX = 7,
}
internal static extern int GdipImageRotateFlip(HandleRef image, int rotateFlipType);
Bitmap oldpic;
int newpicHeight;
int newpicWidth;
private void toolStripButton1_Click(object sender, EventArgs e)
{
newpicHeight = picShow.Image.Height;
newpicWidth = picShow.Image.Width;
newpic = new Bitmap(newpicHeight, newpicWidth);
for (int y = 1; y < oldpic.Width; y++)
{
for (int x = 1; x < oldpic.Height; x++)
{
newColor = oldpic.GetPixel(y,oldpic.Height-x);
newpic.SetPixel(x, y, newColor);
}
picShow.Image = newpic;
}