C#在特定颜色通道中绘制矩形

时间:2014-11-25 11:08:45

标签: c# graphics rectangles drawrectangle

我试图在位图的红色通道中在绿色通道2中绘制2个矩形1。

这是代码:

Bitmap bitmap_guess = new Bitmap(C_PALETTE_X_PIXEL_MAX, C_PALETTE_Y_PIXEL_MAX, PixelFormat.Format24bppRgb);
Graphics graphics = Graphics.FromImage(bitmap_guess);
Rectangle box_rect = new Rectangle(0, 0, C_BOX_PIXELS_WIDTH, C_BOX_PIXELS_HEIGHT);

matrix = new Matrix();
matrix.RotateAt(thc, new System.Drawing.PointF(xc, yc), MatrixOrder.Prepend);
graphics.Transform = matrix;
graphics.FillRectangle(new SolidBrush(Color.Green), xc, yc, box_rect.Width, box_rect.Height);

matrix = new Matrix();
matrix.RotateAt(th, new System.Drawing.PointF(x, y), MatrixOrder.Prepend);
graphics.Transform = matrix;
graphics.FillRectangle(new SolidBrush(Color.Red), x, y, box_rect.Width, box_rect.Height);

问题在于,当我用红色绘制第二个矩形时,它会覆盖第一个与像素重叠的矩形到0' s。我希望矩形在重叠时改变颜色,而不是明显地覆盖先前的像素值。 IE - 在单个频道中绘制而不是全部3个。

我特意为此寻找图形操作。

亲切的问候, Laov

1 个答案:

答案 0 :(得分:0)

这可能会对您有所帮助Merging two images in C#/.NET

然后,您可以将每个矩形绘制到自己的图像中并合并结果...