我有一個位圖,其中我克隆並指定一個矩形 - 當前矩形具有一定的寬度和高度值,我用它來檢查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