我有WritableBitmap
图像,我已经在图像控制 src 中设置。当用户在选定的文本区域上移动时,我正在创建矩形。我还PDFtron SDK
用于从 PDF 文档中获取选定的文本。我们正在WritableBitmap
从 PDF 中获取图像。我们必须逐行选择文本。
我正在使用此代码来绘制屏幕:
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle((int)Math.Min(_downX, x),
(int)Math.Min(_downY, y),
(int)Math.Abs(_downX - x),
(int)Math.Abs(_downY - y));
System.Drawing.Bitmap myBitmap = new System.Drawing.Bitmap(@"D:\PDF\ScreenDraw\WpfApplication1\WpfApplication1\Image\Capture.PNG");
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(myBitmap))
{
System.Drawing.Color customColor = System.Drawing.Color.FromArgb(50, System.Drawing.Color.Red);
System.Drawing.SolidBrush shadowBrush = new System.Drawing.SolidBrush(customColor);
g.FillRectangles(shadowBrush, new System.Drawing.Rectangle[] { rectangle });
}
//myBitmap.Save(@"D:\PDF\abc.png");
//bitmapSource = new BitmapImage(new Uri(@"D:\PDF\abc.png", UriKind.Absolute));
using (var memory = new System.IO.MemoryStream())
{
myBitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
memory.Position = 0;
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = memory;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
Img.Source = bitmapImage;
}
我必须选择如上图所示的文本。