I scaned a image with LEADTOOLS18. and show it in RasterImageViewer.
I want to add text in image.
I use this code.
rasterImageViewer.BeginUpdate();
var container = new RasterImageGdiPlusGraphicsContainer(rasterImageViewer.Image);
container.Graphics.SmoothingMode = SmoothingMode.HighQuality;
Font font = new Font(new FontFamily("Tahoma"), 12);
var point = new PointF(200, 200);
container.Graphics.DrawString("LEADTOOLS", font, new SolidBrush(Color.Red), point);
rasterImageViewer.EndUpdate();
rasterImageViewer.UpdateLayout();
but don't add text!!!
Your code is correct, but it's missing something. When you modify the viewer's Image member, which is a Leadtools.RasterImage, this is not the image that actually gets displayed. It must first get converted to a WPF ImageSource then stored in the viewer's Source property.
When you use one of LEADTOOLS image processing classes, it automatically does this conversion, such as this code:
However, when you use Graphics commands to draw on the image, you need to inform the control that the Image has changed so that the Source gets updated. One way is to Raise the RasterImage.Changed event like this directly after your code:
Another way is to perform the conversion yourself like this: