using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
namespace 转换
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{ } private void button1_Click(object sender, EventArgs e)
{
Bitmap bmp1;
Bitmap bmp2;
string filename = @"C:\Documents and Settings\All Users\Documents\My Pictures\示例图片\Sunset.jpg";
bmp1 = new Bitmap(filename);
bmp2 = new Bitmap(6000, 6000, PixelFormat.Format24bppRgb);
int i =0; int j =0;
for (int x=0; x<bmp1.Width; x++)
{
for (int y = 0; y <bmp1.Height; y++)
{
Color c1 = bmp1.GetPixel(x, y);
bmp2.SetPixel(i,j,c1);
j++; }
i ++;
}
this.pictureBox1.Image = bmp2;
}
}
}
我做了个测试程序,可是总有问题!请高手帮忙解答一下,不胜感激啊!
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
namespace 转换
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{ } private void button1_Click(object sender, EventArgs e)
{
Bitmap bmp1;
Bitmap bmp2;
string filename = @"C:\Documents and Settings\All Users\Documents\My Pictures\示例图片\Sunset.jpg";
bmp1 = new Bitmap(filename);
bmp2 = new Bitmap(6000, 6000, PixelFormat.Format24bppRgb);
int i =0; int j =0;
for (int x=0; x<bmp1.Width; x++)
{
for (int y = 0; y <bmp1.Height; y++)
{
Color c1 = bmp1.GetPixel(x, y);
bmp2.SetPixel(i,j,c1);
j++; }
i ++;
}
this.pictureBox1.Image = bmp2;
}
}
}
我做了个测试程序,可是总有问题!请高手帮忙解答一下,不胜感激啊!
解决方案 »
- 验证接收cookie的页面的时候,是判断cookie不为空,还是cookie.value不为空哈
- 如何遍历一个文件夹下的所有文件和子文件夹
- 关于在FormView中绑定值时需要对字段值做一些处理的问题
- C# winform 未将对象引用设置到对象的实例。 该怎么解决
- 解决jmail接收邮件标题乱码(ASP.NET)
- 哪位大虾帮忙把这个东西加点注释,俺看不懂
- 用vs。net做好的页面到dreamwear mx里面设计视图就看不到内容,但是源代码还是在的,有哪个大哥知道怎么解决吗
- 怎样获取当前的网络速度?
- (C#)FileStream、StreamReader从文件读出来的“中文”怎么没办法显示?
- 求助:类数组定义
- 怎么在客户端改变defaultButton
- 【请教】如何实现C#版本的PriorityBlockingQueue
Message="参数必须为正且小于高度。\r\n参数名: y"
Source="System.Drawing"
ParamName="y"
StackTrace:
错误是这样的,原图像是6000*6000像素的
这句加上校验,改成……
if (j!=bmp1.Height )
{j++;}
注:已经测试通过。但是你的双重循环如果图片过大,机器会倒。N*N次的循环,建议重新找算法或是解决方法。祝好运
多谢帮助哦!