RasterImage ri = iv.Image;
//创建黄色前景图片
Bitmap b1 = new Bitmap(ri.Width, ri.Height);
Graphics g1 = Graphics.FromImage(b1);
g1.FillRectangle(Brushes.Yellow, new Rectangle(0, 0, ri.Width , ri.Height ));
MemoryStream st = new MemoryStream();
b1.Save(st, ImageFormat.Jpeg);
b1.Dispose();
RasterImage destImage = RasterImageConverter.ConvertFromImage(Image.FromStream(st), ConvertFromImageOptions.None);
st.Dispose();
// Combine them
CombineFastCommand command = new CombineFastCommand();
command.DestinationRectangle = new LeadRect(0,0,destImage.Width,destImage.Height);
command.SourcePoint = LeadPoint.Empty;
command.DestinationImage = destImage;
command.Flags = CombineFastCommandFlags.OperationAverage;
command.Run(ri); |