加白边,可以将一张大于原图的白色图片作为背景和这张图片合并,得到一个新的有白边的图像
具体的代码如下,下面代码加了25像素的白边,关于单位转换您可以根据图片的dpi来转换
- SrcImage = _viewerBefore.Image.Clone();
- backImage = new RasterImage(RasterMemoryFlags.Conventional, SrcImage.Width + 50, SrcImage.Height + 50, 24, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, IntPtr.Zero, 0);
- FillCommand Fill = new FillCommand();
- Fill.Color = Leadtools.Demos.Converters.FromGdiPlusColor(Color.White);
- Fill.Run(backImage);
- CombineCommand Combine = new CombineCommand();
- Combine.DestinationRectangle = new LeadRect(25, 25, SrcImage.Width, SrcImage.Height);
- Combine.SourcePoint = new LeadPoint(0, 0);
- Combine.SourceImage = SrcImage;
- Combine.Run(backImage);
- _viewerAfter.Image = backImage.Clone();
复制代码 |