我有一个位图,其中我克隆并指定一个矩形 - 当前矩形具有一定的宽度和高度值,我用它来检查QR码的矩形。我注意到这个检查左上角。我可以改变这个来检查右上角,右下角和左下角的相同尺寸(宽度和高度)?绘制矩形的位图克隆
Bitmap result = fullImg.Clone(new System.Drawing.Rectangle(0, 0, 375, 375), fullImg.PixelFormat);
任何帮助,非常感谢。对于QR
for (int pg = 0; pg < inputDocument.PageCount; pg++)
{
string workGif = workingFilename.Replace(".pdf", string.Format(".{0}.gif", pg + 1));
GhostscriptWrapper.GeneratePageThumb(workingFilename, workGif, pg + 1, 300, 300); // size (last two params) does not seem to have any effect
using (var fullImg = new Bitmap(workGif))
{
Bitmap result = fullImg.Clone(new System.Drawing.Rectangle(0, 0, 375, 375), fullImg.PixelFormat);
string QRinfo = Process(result);
MessageBox.Show(QRinfo);
string[] qcode = QRinfo.Split('/');
string gid = qcode[qcode.Count() - 1];
Guid pgGuid = new Guid(gid);
}
}
加工方法
public string Process(Bitmap bitmap)
{
var reader = new com.google.zxing.qrcode.QRCodeReader();
try
{
LuminanceSource source = new RGBLuminanceSource(bitmap, bitmap.Width, bitmap.Height);
var binarizer = new HybridBinarizer(source);
var binBitmap = new BinaryBitmap(binarizer);
return reader.decode(binBitmap).Text;
}
catch (Exception e)
{
return e.Message;
}
}
你会用这个来达到什么目的?一个矩形有一个Point和一个Size,并且Point总是考虑左上角的位置来计算的。 – GuFigueiredo 2013-03-07 20:29:48
@GuFigueiredo我想找出一种方法来检测页面上的二维码,并根据它的位置我想旋转它,使二维码在左上角。我如何查找整个页面中的qr代码并找到它的位置来旋转? – Masriyah 2013-03-07 20:32:22
你能提供更多信息吗?您在Windows窗体中具有qr代码还是ASP.NET页面?这些元素如何加载到控件中? – GuFigueiredo 2013-03-07 20:41:04