【发布时间】:2013-03-01 22:51:02
【问题描述】:
目前我有这种方法可以在页面的左上角绘制一个矩形。我想创建另一种方法,该方法将在扫描文档的四个角中的任何一个中搜索矩形绘图。 我该如何编写一种方法,该方法将根据我为绘制矩形创建的内容检查矩形绘图的每个角。
static void AddQRTag(PdfSharp.Drawing.XGraphics gfx, int xPosition, int yPosition, string QRdata, string HRdata)
{
gfx.DrawRectangle(XBrushes.White, xPosition, yPosition, xPosition + 55, yPosition + 85);
PdfSharp.Drawing.XImage xImage =
PdfSharp.Drawing.XImage.FromGdiPlusImage(BuildQR(QRdata.ToUpper(), 3,
QRCodeEncoder.ENCODE_MODE.ALPHA_NUMERIC, 2, QRCodeEncoder.ERROR_CORRECTION.M));
gfx.DrawImage(xImage, xPosition + 5, yPosition + 5, xImage.PixelWidth * .8, xImage.PixelWidth * .8);
//XFont font = new XFont("OCR B", 10, XFontStyle.Bold);
XFont font = new XFont("OCR B", 6);
XTextFormatter tf = new XTextFormatter(gfx);
tf.Alignment = XParagraphAlignment.Left;
//XStringFormat format = new XStringFormat();
//format.Alignment = XStringAlignment.Near;
XRect layout = new XRect(xPosition + 5, yPosition + 55, 55, 30);
tf.DrawString(HRdata.ToUpper(), font, XBrushes.Black, layout, XStringFormats.TopLeft);
//gfx.DrawString(HRdata, font, XBrushes.Black,layout,format);
}
【问题讨论】:
-
你想用图像处理技术找到矩形吗?
-
@OopsUser 我不确定什么是最有效的。我正在阅读有关使用 itextSharp 的信息,但我不确定什么是最好的方法。在页面的所有四个角中查找图像更好还是检查一个角并旋转文档直到找到图像(位图)。