1

我上网查了一下,看到用ZXing解二维码。但是代码我看不懂。

PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource( data, width, height, dstLeft, dstTop, dstWidth,dstHeight, false);

参数的含义是什么?

4

1 回答 1

1

I went to read the ZXing source code and I found the following (There was no constructor with boolean parameter in the end)

PlanarYUVLuminanceSource(byte[] yuvData, int dataWidth, int dataHeight, int left, 
   int top, int width, int height) 
{
   super(width, height);

   if (left + width > dataWidth || top + height > dataHeight) 
   {
      throw new IllegalArgumentException("Crop rectangle does not fit within image data.");
   }

   this.yuvData = yuvData;
   this.dataWidth = dataWidth;
   this.dataHeight = dataHeight;
   this.left = left;
   this.top = top;
}

When I read the code I understand the following (I have an assumption that the relevant data consider only as the area of the inner rectangle of where the QR code should be placed in the image).
byte[] yuvData - The byte array that contain the data of the image. All the data the one inside the rectangle and outside of it.
int dataWidth - The width of the data. The width of the data all the area outside and inside the rectangle.
int dataHeight - The Height of the data. The height of the data all the area outside and inside the rectangle.
int left - The left border of the rectangle. Or, how many pixels are outside of the rectangle from the left.
int top - The top border of the rectangle. Or, how many pixels are outside of the rectangle from the top.
int width - The width of the inner rectangle.
int height - The height of the inner rectangle.

于 2012-11-19T10:14:52.620 回答