当前位置: 首页>>代码示例>>Java>>正文


Java BitMatrix.getHeight方法代码示例

本文整理汇总了Java中com.google.zxing.common.BitMatrix.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java BitMatrix.getHeight方法的具体用法?Java BitMatrix.getHeight怎么用?Java BitMatrix.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.zxing.common.BitMatrix的用法示例。


在下文中一共展示了BitMatrix.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createQRCode

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
public static Bitmap createQRCode(String str,int widthAndHeight) throws WriterException {
	Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();  
       hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); 
	BitMatrix matrix = new MultiFormatWriter().encode(str,
			BarcodeFormat.QR_CODE, widthAndHeight, widthAndHeight);
	int width = matrix.getWidth();
	int height = matrix.getHeight();
	int[] pixels = new int[width * height];
	
	for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
			if (matrix.get(x, y)) {
				pixels[y * width + x] = BLACK;
			}
		}
	}
	Bitmap bitmap = Bitmap.createBitmap(width, height,
			Bitmap.Config.ARGB_8888);
	bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
	return bitmap;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:EncodingHandler.java

示例2: createQRCode

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
public static Bitmap createQRCode(String str, int widthAndHeight) throws WriterException {
    Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
    hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
    BitMatrix matrix = new MultiFormatWriter().encode(str,
            BarcodeFormat.QR_CODE, widthAndHeight, widthAndHeight);
    int width = matrix.getWidth();
    int height = matrix.getHeight();
    int[] pixels = new int[width * height];

    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            if (matrix.get(x, y)) {
                pixels[y * width + x] = BLACK;
            }
        }
    }
    Bitmap bitmap = Bitmap.createBitmap(width, height,
            Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
    return bitmap;
}
 
开发者ID:guxiaonian,项目名称:MeiLa_GNN,代码行数:22,代码来源:EncodingHandler.java

示例3: createQRCode

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
public static Bitmap createQRCode(String str,int widthAndHeight) throws WriterException {
	Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
       hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
	BitMatrix matrix = new MultiFormatWriter().encode(str,
			BarcodeFormat.QR_CODE, widthAndHeight, widthAndHeight);
	int width = matrix.getWidth();
	int height = matrix.getHeight();
	int[] pixels = new int[width * height];
	
	for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
			if (matrix.get(x, y)) {
				pixels[y * width + x] = BLACK;
			}
		}
	}
	Bitmap bitmap = Bitmap.createBitmap(width, height,
			Bitmap.Config.ARGB_8888);
	bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
	return bitmap;
}
 
开发者ID:kkyflying,项目名称:CodeScaner,代码行数:22,代码来源:EncodingHandler.java

示例4: createImage

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
private static BufferedImage createImage(String content, String imgPath,
        boolean needCompress) throws Exception {
    Hashtable hints = new Hashtable();
    hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
    hints.put(EncodeHintType.CHARACTER_SET, CHARSET);
    hints.put(EncodeHintType.MARGIN, 1);
    BitMatrix bitMatrix = new MultiFormatWriter().encode(content,
            BarcodeFormat.QR_CODE, QRCODE_SIZE, QRCODE_SIZE, hints);
    int width = bitMatrix.getWidth();
    int height = bitMatrix.getHeight();
    BufferedImage image = new BufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB);
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000
                    : 0xFFFFFFFF);
        }
    }
    if (imgPath == null || "".equals(imgPath)) {
        return image;
    }
 // 插入图片
    CodeUtil.insertImage(image, imgPath, needCompress);
    return image;
}
 
开发者ID:Fetax,项目名称:Fetax-AI,代码行数:26,代码来源:CodeUtil.java

示例5: create

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
public static @NonNull Bitmap create(String data) {
  try {
    BitMatrix result = new QRCodeWriter().encode(data, BarcodeFormat.QR_CODE, 512, 512);
    Bitmap    bitmap = Bitmap.createBitmap(result.getWidth(), result.getHeight(), Bitmap.Config.ARGB_8888);

    for (int y = 0; y < result.getHeight(); y++) {
      for (int x = 0; x < result.getWidth(); x++) {
        if (result.get(x, y)) {
          bitmap.setPixel(x, y, Color.BLACK);
        }
      }
    }

    return bitmap;
  } catch (WriterException e) {
    Log.w(TAG, e);
    return Bitmap.createBitmap(512, 512, Bitmap.Config.ARGB_8888);
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:20,代码来源:QrCode.java

示例6: createQrCode

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
@Nullable
static Bitmap createQrCode(DisplayMetrics dm, String input) {
	int smallestDimen = Math.min(dm.widthPixels, dm.heightPixels);
	try {
		// Generate QR code
		final BitMatrix encoded = new QRCodeWriter().encode(
				input, QR_CODE, smallestDimen, smallestDimen);
		// Convert QR code to Bitmap
		int width = encoded.getWidth();
		int height = encoded.getHeight();
		int[] pixels = new int[width * height];
		for (int x = 0; x < width; x++) {
			for (int y = 0; y < height; y++) {
				pixels[y * width + x] = encoded.get(x, y) ? BLACK : WHITE;
			}
		}
		Bitmap qr = Bitmap.createBitmap(width, height, ARGB_8888);
		qr.setPixels(pixels, 0, width, 0, 0, width, height);
		return qr;
	} catch (WriterException e) {
		if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
		return null;
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:25,代码来源:QrCodeUtils.java

示例7: encodeAsBitmap

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
static Bitmap encodeAsBitmap(String contents, BarcodeFormat format,
                             int desiredWidth, int desiredHeight) throws WriterException {
    Hashtable<EncodeHintType, Object> hints = null;
    String encoding = guessAppropriateEncoding(contents);
    if (encoding != null) {
        hints = new Hashtable<EncodeHintType, Object>(2);
        hints.put(EncodeHintType.CHARACTER_SET, encoding);
    }
    MultiFormatWriter writer = new MultiFormatWriter();
    BitMatrix result = writer.encode(contents, format, desiredWidth,
            desiredHeight, hints);
    int width = result.getWidth();
    int height = result.getHeight();
    int[] pixels = new int[width * height];
    // All are 0, or black, by default
    for (int y = 0; y < height; y++) {
        int offset = y * width;
        for (int x = 0; x < width; x++) {
            pixels[offset + x] = result.get(x, y) ? BLACK : WHITE;
        }
    }

    Bitmap bitmap = Bitmap.createBitmap(width, height,
            Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
    return bitmap;
}
 
开发者ID:guzhigang001,项目名称:Zxing,代码行数:28,代码来源:QRCodeEncoder.java

示例8: buildImage

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
private Image buildImage(BarcodeFormat format,String data,int w,int h){
       try{
       	Map<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();  
           hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
           hints.put(EncodeHintType.MARGIN,0);
           if(format.equals(BarcodeFormat.QR_CODE)){
           	hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);            	
           }
           BitMatrix matrix = new MultiFormatWriter().encode(data,format, w, h,hints);
           int width = matrix.getWidth();  
           int height = matrix.getHeight();
           BufferedImage image = new BufferedImage(width, height,BufferedImage.TYPE_INT_ARGB);
           for (int x = 0; x < width; x++) {
           	for (int y = 0; y < height; y++) {
           		image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE);
           	}
           }
           ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
           ImageIO.write(image, "png", outputStream);
           byte[] bytes=outputStream.toByteArray();
           String base64Data=Base64Utils.encodeToString(bytes);
           IOUtils.closeQuietly(outputStream);
           return new Image(base64Data,w,h);
       }catch(Exception ex){
       	throw new ReportComputeException(ex);
       }
}
 
开发者ID:youseries,项目名称:ureport,代码行数:28,代码来源:ZxingValueCompute.java

示例9: create

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
/**
 * Create and return your Image here.
 * NOTE: make sure, your class is public and has a public default constructor!
 *
 * @param tag    The dialog-fragments tag
 * @param extras The extras supplied to {@link SimpleImageDialog#extra(Bundle)}
 * @return the image to be shown
 */
@Override
public Bitmap create(@Nullable String tag, @NonNull Bundle extras) {
    String content = extras.getString(QR_CONTENT);
    if (content == null) return null;

    // Generate
    try {
        EnumMap<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class);
        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.Q);
        hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
        BitMatrix bitMatrix = new QRCodeWriter().encode(content, BarcodeFormat.QR_CODE,
                1024, 1024, hints);
        int width = bitMatrix.getWidth(), height = bitMatrix.getHeight();
        int[] pixels = new int[width * height];
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                pixels[y*width + x] = bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE;
            }
        }
        Bitmap qr = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
        qr.setPixels(pixels, 0, width, 0, 0, width, height);
        return qr;

    } catch (WriterException ignored) {}

    return null;
}
 
开发者ID:eltos,项目名称:SimpleDialogFragments,代码行数:36,代码来源:MainActivity.java

示例10: BitMatrixParser

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
BitMatrixParser(BitMatrix bitMatrix) throws FormatException {
    int dimension = bitMatrix.getHeight();
    if (dimension < 21 || (dimension & 3) != 1) {
        throw FormatException.getFormatInstance();
    }
    this.bitMatrix = bitMatrix;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:BitMatrixParser.java

示例11: BitMatrixParser

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
BitMatrixParser(BitMatrix bitMatrix) throws FormatException {
    int dimension = bitMatrix.getHeight();
    if (dimension < 8 || dimension > 144 || (dimension & 1) != 0) {
        throw FormatException.getFormatInstance();
    }
    this.version = readVersion(bitMatrix);
    this.mappingBitMatrix = extractDataRegion(bitMatrix);
    this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getWidth(), this
            .mappingBitMatrix.getHeight());
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:BitMatrixParser.java

示例12: WhiteRectangleDetector

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
public WhiteRectangleDetector(BitMatrix image) throws NotFoundException {
    this(image, 10, image.getWidth() / 2, image.getHeight() / 2);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:WhiteRectangleDetector.java

示例13: createQRCodeWithLogo

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
/**
     * 生成带Logo的二维码
     *
     * @param content 二维码内容
     * @param size    二维码内容大小
     * @param bitmap  二维码Logo
     * @param color   二维码颜色
     */
    public static Bitmap createQRCodeWithLogo(String content, int size, Bitmap bitmap, int color) {
        try {
            int logoHalfWidth = size / 10;
            Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
            hints.put(EncodeHintType.CHARACTER_SET, CHARACTER_SET);
            // 设置容错级别,默认为ErrorCorrectionLevel.L
            // 因为中间加入logo所以建议你把容错级别调至H,否则可能会出现识别不了
            hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
            hints.put(EncodeHintType.MARGIN, 2); // default is 4
//            hints.put(EncodeHintType.MAX_SIZE, 350);
//            hints.put(EncodeHintType.MIN_SIZE, 100);
            BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, size, size, hints);
            // 将logo图片按martix设置的信息缩放
            bitmap = Bitmap.createScaledBitmap(bitmap, size, size, false);
            int width = bitMatrix.getWidth(); // 矩阵高度
            int height = bitMatrix.getHeight(); // 矩阵宽度
            int halfW = width / 2;
            int halfH = height / 2;
            Matrix matrix = new Matrix();
            float sx = (float) 2 * logoHalfWidth / bitmap.getWidth();
            float sy = (float) 2 * logoHalfWidth / bitmap.getHeight();
            matrix.setScale(sx, sy);
            // 设置缩放信息
            // 将logo图片按martix设置的信息缩放
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false);
            int[] pixels = new int[size * size];
            for (int y = 0; y < size; y++) {
                for (int x = 0; x < size; x++) {
                    if (x > halfW - logoHalfWidth
                            && x < halfW + logoHalfWidth
                            && y > halfH - logoHalfWidth
                            && y < halfH + logoHalfWidth) {
                        //该位置用于存放图片信息
                        //记录图片每个像素信息
                        pixels[y * width + x] = bitmap.getPixel(x - halfW + logoHalfWidth, y - halfH + logoHalfWidth);
                    } else {
                        if (bitMatrix.get(x, y)) {
                            pixels[y * size + x] = color;
                        } else {
                            pixels[y * size + x] = WHITE;
                        }
                    }
                }
            }
            Bitmap result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
            // 通过像素数组生成bitmap
            result.setPixels(pixels, 0, size, 0, 0, size, size);
            return result;
        } catch (WriterException e) {
            return null;
        }
    }
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:61,代码来源:QRCodeHelper.java

示例14: crossCheckVertical

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
private float crossCheckVertical(int startI, int centerJ, int maxCount, int
        originalStateCountTotal) {
    BitMatrix image = this.image;
    int maxI = image.getHeight();
    int[] stateCount = this.crossCheckStateCount;
    stateCount[0] = 0;
    stateCount[1] = 0;
    stateCount[2] = 0;
    int i = startI;
    while (i >= 0 && image.get(centerJ, i) && stateCount[1] <= maxCount) {
        stateCount[1] = stateCount[1] + 1;
        i--;
    }
    if (i < 0 || stateCount[1] > maxCount) {
        return Float.NaN;
    }
    while (i >= 0 && !image.get(centerJ, i) && stateCount[0] <= maxCount) {
        stateCount[0] = stateCount[0] + 1;
        i--;
    }
    if (stateCount[0] > maxCount) {
        return Float.NaN;
    }
    i = startI + 1;
    while (i < maxI && image.get(centerJ, i) && stateCount[1] <= maxCount) {
        stateCount[1] = stateCount[1] + 1;
        i++;
    }
    if (i == maxI || stateCount[1] > maxCount) {
        return Float.NaN;
    }
    while (i < maxI && !image.get(centerJ, i) && stateCount[2] <= maxCount) {
        stateCount[2] = stateCount[2] + 1;
        i++;
    }
    if (stateCount[2] > maxCount || Math.abs(((stateCount[0] + stateCount[1]) +
            stateCount[2]) - originalStateCountTotal) * 5 >= originalStateCountTotal * 2 ||
            !foundPatternCross(stateCount)) {
        return Float.NaN;
    }
    return centerFromEnd(stateCount, i);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:43,代码来源:AlignmentPatternFinder.java

示例15: crossCheckVertical

import com.google.zxing.common.BitMatrix; //导入方法依赖的package包/类
/**
 * <p>After a horizontal scan finds a potential alignment pattern, this method
 * "cross-checks" by scanning down vertically through the center of the possible
 * alignment pattern to see if the same proportion is detected.</p>
 *
 * @param startI row where an alignment pattern was detected
 * @param centerJ center of the section that appears to cross an alignment pattern
 * @param maxCount maximum reasonable number of modules that should be
 * observed in any reading state, based on the results of the horizontal scan
 * @return vertical center of alignment pattern, or {@link Float#NaN} if not found
 */
private float crossCheckVertical(int startI, int centerJ, int maxCount,
    int originalStateCountTotal) {
  BitMatrix image = this.image;

  int maxI = image.getHeight();
  int[] stateCount = crossCheckStateCount;
  stateCount[0] = 0;
  stateCount[1] = 0;
  stateCount[2] = 0;

  // Start counting up from center
  int i = startI;
  while (i >= 0 && image.get(centerJ, i) && stateCount[1] <= maxCount) {
    stateCount[1]++;
    i--;
  }
  // If already too many modules in this state or ran off the edge:
  if (i < 0 || stateCount[1] > maxCount) {
    return Float.NaN;
  }
  while (i >= 0 && !image.get(centerJ, i) && stateCount[0] <= maxCount) {
    stateCount[0]++;
    i--;
  }
  if (stateCount[0] > maxCount) {
    return Float.NaN;
  }

  // Now also count down from center
  i = startI + 1;
  while (i < maxI && image.get(centerJ, i) && stateCount[1] <= maxCount) {
    stateCount[1]++;
    i++;
  }
  if (i == maxI || stateCount[1] > maxCount) {
    return Float.NaN;
  }
  while (i < maxI && !image.get(centerJ, i) && stateCount[2] <= maxCount) {
    stateCount[2]++;
    i++;
  }
  if (stateCount[2] > maxCount) {
    return Float.NaN;
  }

  int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
  if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) {
    return Float.NaN;
  }

  return foundPatternCross(stateCount) ? centerFromEnd(stateCount, i) : Float.NaN;
}
 
开发者ID:10045125,项目名称:QrCode,代码行数:64,代码来源:AlignmentPatternFinder.java


注:本文中的com.google.zxing.common.BitMatrix.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。