Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

generate sampling grid from both Finder Pattern and Alignment Pattern

  • Loading branch information...
commit c9fcee32db4d5f639f0597cf594c33dc324f8abc 1 parent 4eed647
@yanbe authored
Showing with 12 additions and 15 deletions.
  1. +12 −15 qrcode/SamplingGrid.as
View
27 qrcode/SamplingGrid.as
@@ -4,25 +4,22 @@ package qrcode {
public class SamplingGrid {
public static function samplePixels(pixels:BitmapData, finderPattern:Object,
- alignmentPattern:Object=null, debug:BitmapData=null):BitmapData {
+ alignmentPattern:Array=null, debug:BitmapData=null):BitmapData {
// based on table 1 on JIS-X-0510:2004 p.13
- var sideLength:int = 17+finderPattern.roughVersion*4;
- var sampledPixels:BitmapData = new BitmapData(sideLength, sideLength);
- var mapper:PixelMapper = new PixelMapper(finderPattern);
+ var sampledPixels:BitmapData = new BitmapData(finderPattern.sideLength,
+ finderPattern.sideLength);
- if (alignmentPattern==null) { // should be version 6 or lower
- for (var y:int=0; y<sideLength; y++) {
- for (var x:int=0; x<sideLength; x++) {
- var srcPoint:Point = mapper.mapPixel(x, y);
- var sampledPattern:uint = pixels.getPixel(srcPoint.x, srcPoint.y);
- sampledPixels.setPixel(x, y, sampledPattern);
- debug.setPixel(srcPoint.x, srcPoint.y, 0xff0000);
- }
+ var mapper:PixelMapper = new PixelMapper(finderPattern, alignmentPattern);
+
+ for (var y:int=0; y<finderPattern.sideLength; y++) {
+ for (var x:int=0; x<finderPattern.sideLength; x++) {
+ var srcPoint:Point = mapper.mapPixel(x, y);
+ var sampledPattern:uint = pixels.getPixel(srcPoint.x, srcPoint.y);
+ sampledPixels.setPixel(x, y, sampledPattern);
+ debug.setPixel(srcPoint.x, srcPoint.y, 0xff0000);
}
- return sampledPixels;
- } else {
- return sampledPixels;
}
+ return sampledPixels;
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.