Question
How to highlight text on the source image?
Answer
To highlight text in a source image:
-
Create a region where the text should be highlighted. You can either set its coordinates manually or acquire them automatically as described in the Text Coordinates article.
- Create an ImageModification object and add a paint region and a ReplaceBlackPixels region to it.
- Modify the image and save it.
Sample Code in C#
//load image
FREngine.FRDocument document = engineLoader.Engine.CreateFRDocumentFromImage(@"D:\Demo.tif");
//create the region where the text should be highlighted
FREngine.Region region = engineLoader.Engine.CreateRegion();
region.AddRect(350,280,1000,350);
//create ImageModificaton object and add paint region and “replace black pixels region” to it
FREngine.ImageModification imageModification = engineLoader.Engine.CreateImageModification();
imageModification.AddPaintRegion(region, 255);
imageModification.AddReplaceBlackPixelsRegion(region, 0);
//modify the image and save it
document.Pages[0].ImageDocument.ColorImage.WriteToFile(@"D:\highlighted.tif",
FREngine.ImageFileFormatEnum.IFF_TiffColorLZW, imageModification);
Comments
0 comments
Please sign in to leave a comment.