参数必须为正且小于高度。参数名: y"
privatevoid变换灰度ToolStripMenuItem_Click(objectsender,EventArgse){Colorc=newColor();Bit...
private void 变换灰度ToolStripMenuItem_Click(object sender, EventArgs e)
{
Color c = new Color();
Bitmap b = new Bitmap(pictureBox1.Image);
int rr, gg, bb, cc;
for (int i = 0; i < pictureBox1.Width; i++)
{
for (int j = 0; j < pictureBox1.Height; j++)
{
c = b.GetPixel(i,j);
rr = c.B;
gg = c.G;
bb = c.B;
cc = (int)((rr + gg + bb) / 3);
if(cc<0)cc=0;
if (cc > 255) cc = 255;
Color c1=Color.FromArgb(cc,cc,cc);
b.SetPixel(i,j,c1);
}
pictureBox1.Refresh();
pictureBox1.Image = b;
}
}
想把图片变为灰色图片,但出现了问题,恳请
请各位帮忙~ 展开
{
Color c = new Color();
Bitmap b = new Bitmap(pictureBox1.Image);
int rr, gg, bb, cc;
for (int i = 0; i < pictureBox1.Width; i++)
{
for (int j = 0; j < pictureBox1.Height; j++)
{
c = b.GetPixel(i,j);
rr = c.B;
gg = c.G;
bb = c.B;
cc = (int)((rr + gg + bb) / 3);
if(cc<0)cc=0;
if (cc > 255) cc = 255;
Color c1=Color.FromArgb(cc,cc,cc);
b.SetPixel(i,j,c1);
}
pictureBox1.Refresh();
pictureBox1.Image = b;
}
}
想把图片变为灰色图片,但出现了问题,恳请
请各位帮忙~ 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询