不明白你怎么合... Red + green = yellow?这样

解决方案 »

  1.   

    比如说 图A中有一红色的矩形,叠加到图B上时为一为红色且通明的矩形(能够看到原图A的东西,但就是蒙上了一层通明的红色)
      

  2.   

    我写了个demo,可以实现了。private void button1_Click(object sender, EventArgs e)
            {
                Color c = new Color();
                Bitmap box1 = new Bitmap(pictureBox1.Image);
                Bitmap box2 = new Bitmap(pictureBox2.Image);
                Bitmap box3 = new Bitmap(pictureBox2.Image);
                for (int i = 0; i < pictureBox1.Image.Width; i++)
                {
                    for (int j = 0; j < pictureBox1.Image.Height; j++)
                    {
                        c = box2.GetPixel(i, j);  //去Picture2的颜色。                    if (c == Color.FromArgb(255,255,255))
                        {
                            c = box1.GetPixel(i, j); //如果是白色就取Picture1的颜色                    }
                        if (c == Color.FromArgb(255, 0, 0))
                        {
                            c = Color.FromArgb(20, c); //如果是红色就做半透明处理Alpha = 20;
                        }                    box3.SetPixel(i, j, c);
                    }
                    pictureBox1.Refresh();
                    pictureBox1.Image = box3;
                }        }
    注意两个PictureBox的属性设置,否则会造成益处: this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage")));
                this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
                this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
                this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
                this.pictureBox1.Location = new System.Drawing.Point(41, 60);
                this.pictureBox1.Name = "pictureBox1";
                this.pictureBox1.Size = new System.Drawing.Size(243, 224);
                this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
                this.pictureBox1.TabIndex = 0;
                this.pictureBox1.TabStop = false;
                // 
                // pictureBox2
                // 
                this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
                this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
                this.pictureBox2.Location = new System.Drawing.Point(338, 60);
                this.pictureBox2.Name = "pictureBox2";
                this.pictureBox2.Size = new System.Drawing.Size(243, 224);
                this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
                this.pictureBox2.TabIndex = 1;
                this.pictureBox2.TabStop = false;
      

  3.   

    使用 System.Drawing.Drawing2D.Matrix 改变Alpha值。
    Matrix是一个矩阵,从0-1成倍的变换。
      

  4.   

    把IMAGE2转换成灰度图 fb(,),其中的黑白色不变,红色成了灰色。
    将fB(,) 的值调整为 0~1 之前的浮点数。
    将fB(,)做为 Image2 叠加的透明通道,即 fLast (,) = Image1(,) + Image2(,) * fB(,);
     
      

  5.   

    明白了点
    你先知道 你红色的区域..并获取到Rectangle
    使用
    Grapchis.FillRectangle(new SolidBrush(Color.FromArgb(0,255,255,255)) 
    绘制成全透明的图
    Grapchis.FillRectangle(new SolidBrush(Color.FromArgb(100, 255, 255, 255))
    然后绘制成半透明的图.然后把这个图形绘制到你要绘制的地方就可以了.. 你试下没试过:)
      

  6.   

    错误 1 当前上下文中不存在名称“resources” C:\Documents and Settings\Administrator\桌面\565465\WindowsApplication1\WindowsApplication1\Form1.cs 49 72 WindowsApplication1
    请问下面的resources是什么对象啊????
    this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage")));