SizeCommand这个是用于更改图像整体尺寸的,但是看你需要的效果似乎更类似于PS中更改画布大小的操作
在leadtools中,可以通过CombineCommand命令,叠加两个图像来完成
背景图:填充白色的新建rasterimage ,尺寸大于前景图
前景图:原图
两个图片执行CombineCommand命令叠加后就是你要的效果,
附上代码和效果
- RasterImage SrcImage, backImage;
- RasterCodecs _codecs;
- _codecs = new RasterCodecs();
- 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(0, 0, SrcImage.Width, SrcImage.Height);
- Combine.SourcePoint = new LeadPoint(0, 0);
- Combine.SourceImage = SrcImage;
- Combine.Run(backImage);
- _viewerAfter.Image = backImage.Clone();
复制代码
|