将二维码图片解码为文本

@param image {@link Image} 二维码图片
@param isTryHarder 是否优化精度
@param isPureBarcode 是否使用复杂模式，扫描带logo的二维码设为true
@return 解码后的文本
@since 4.3.1
358087
public static String decode(Image image, boolean isTryHarder, boolean isPureBarcode) {
		final MultiFormatReader formatReader = new MultiFormatReader();

		final LuminanceSource source = new BufferedImageLuminanceSource(ImgUtil.toBufferedImage(image));
		final Binarizer binarizer = new HybridBinarizer(source);
		final BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer);

		final HashMap<DecodeHintType, Object> hints = new HashMap<>();
		hints.put(DecodeHintType.CHARACTER_SET, CharsetUtil.UTF_8);
		// 优化精度
		hints.put(DecodeHintType.TRY_HARDER, Boolean.valueOf(isTryHarder));
		// 复杂模式，开启PURE_BARCODE模式
		hints.put(DecodeHintType.PURE_BARCODE, Boolean.valueOf(isPureBarcode));
		Result result;
		try {
			result = formatReader.decode(binaryBitmap, hints);
		} catch (NotFoundException e) {
			// 报错尝试关闭复杂模式
			hints.remove(DecodeHintType.PURE_BARCODE);
			try {
				result = formatReader.decode(binaryBitmap, hints);
			} catch (NotFoundException e1) {
				throw new QrCodeException(e1);
			}
		}

		return result.getText();
	}
257008
public BufferedImage put(IconRow iconRow, BufferedImage image) {
		return put(iconRow.getId(), image);
	}
790580
public ImageDescriptor image(SarlConstructor constructor) {
		if (constructor.isStatic()) {
			return this.images.forStaticConstructor();
		}
		return this.images.forConstructor(
				constructor.getVisibility(),
				this.adornments.get(this.jvmModelAssociations.getInferredConstructor(constructor)));
	}
520965
public boolean process(T image , QrCode qr ) {
		this.qr = qr;
		// this must be cleared before calling setMarker or else the distortion will be messed up
		qr.alignment.reset();

		reader.setImage(image);
		reader.setMarker(qr);

		threshold = (float)qr.threshCorner;

		initializePatterns(qr);

		// version 1 has no alignment patterns
		if( qr.version <= 1 )
			return true;
		return localizePositionPatterns(QrCode.VERSION_INFO[qr.version].alignment);
	}
856802
private static String getFullImagePath(String imgSrc, BinaryResourcesHandler binaryRsHandler,
			HttpServletRequest request) {

		String contextPath = request.getContextPath();
		// relative path
		if (!binaryRsHandler.getConfig().getGeneratorRegistry().isGeneratedBinaryResource(imgSrc)
				&& !imgSrc.startsWith("/")) {
			imgSrc = PathNormalizer.concatWebPath(request.getRequestURI(), imgSrc);
			int idx = imgSrc.indexOf(contextPath);
			if (idx > -1) {
				imgSrc = imgSrc.substring(idx + contextPath.length());
			}
		}
		return imgSrc;
	}
205586
public void validateImageType(BufferedImage image) {
		if (image == null) {
			throw new GeoPackageException("The image is null");
		}
		if (image.getColorModel().getTransferType() != DataBuffer.TYPE_USHORT) {
			throw new GeoPackageException(
					"The coverage data tile is expected to be a 16 bit unsigned short, actual: "
							+ image.getColorModel().getTransferType());
		}
	}
830009
public static String getImageUrl(String imgSrc, PageContext pageContext) {
		BinaryResourcesHandler imgRsHandler = (BinaryResourcesHandler) pageContext.getServletContext()
				.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
		if (null == imgRsHandler)
			throw new JawrLinkRenderingException(
					"You are using a Jawr image tag while the Jawr Image servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred.");

		HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();

		HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

		return getImageUrl(imgSrc, imgRsHandler, request, response);

	}
1111249
private static byte[] getByteArray(BufferedImage image) {
    checkNotNull(image);

    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    try {
      ImageIO.write(image, "png", stream);
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }

    return stream.toByteArray();
  }
1125783
public ImageDescriptor getTypeImageDescriptor(
			SarlElementType type,
			boolean isInner) {
		return getTypeImageDescriptor(type, isInner, false, 0, USE_LIGHT_ICONS);
	}
89094
protected String getImgSrcToRender() throws JspException {

		BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) pageContext.getServletContext()
				.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);
		if (null == binaryRsHandler)
			throw new JspException(
					"You are using a Jawr image tag while the Jawr Binary servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred.");

		HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();

		HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

		return ImageTagUtils.getImageUrl(src, base64, binaryRsHandler, request, response);
	}
781481
public static boolean isFullyTransparent(BufferedImage image) {
		boolean transparent = true;
		for (int x = 0; x < image.getWidth(); x++) {
			for (int y = 0; y < image.getHeight(); y++) {
				transparent = isTransparent(image, x, y);
				if (!transparent) {
					break;
				}
			}
			if (!transparent) {
				break;
			}
		}
		return transparent;
	}
1002328
public static boolean isBlack(BufferedImage image, int x, int y) {
        if (image.getType() == BufferedImage.TYPE_BYTE_BINARY) {
            WritableRaster raster = image.getRaster();
            int pixelRGBValue = raster.getSample(x, y, 0);
            return pixelRGBValue == 0;
        }

        int luminanceValue = 140;
        return isBlack(image, x, y, luminanceValue);
    }
1028989
public static BufferedImage toBufferedImage(final Image image) {
        if (image instanceof BufferedImage) {
            return (BufferedImage) image;
        }

        // Create a buffered image with transparency
        final BufferedImage bufferedImage =
                new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);

        final Graphics2D bufferedGraphics = bufferedImage.createGraphics();
        bufferedGraphics.drawImage(image, 0, 0, null);
        bufferedGraphics.dispose();

        // Return the buffered image
        return bufferedImage;
    }
272866
public static int[] getRGB(BufferedImage image) {
		int[] pixels = getRGBArray(image);
		getRGB(image, pixels);
		return pixels;
	}
1000358
function isTokenChar(code) {
  return code === 0x21                // '!'
    || code >= 0x23 && code <= 0x27   // '#', '$', '%', '&', '''
    || code === 0x2A                  // '*'
    || code === 0x2B                  // '+'
    || code === 0x2D                  // '-'
    || code === 0x2E                  // '.'
    || code >= 0x30 && code <= 0x39   // 0-9
    || code >= 0x41 && code <= 0x5A   // A-Z
    || code >= 0x5E && code <= 0x7A   // '^', '_', '`', a-z
    || code === 0x7C                  // '|'
    || code === 0x7E;                 // '~'
}
803383
public static BufferedImage toBufferedImage(Image image, String imageType) {
		BufferedImage bufferedImage;
		if (false == imageType.equalsIgnoreCase(IMAGE_TYPE_PNG)) {
			// 当目标为非PNG类图片时，源图片统一转换为RGB格式
			if (image instanceof BufferedImage) {
				bufferedImage = (BufferedImage) image;
				if (BufferedImage.TYPE_INT_RGB != bufferedImage.getType()) {
					bufferedImage = copyImage(image, BufferedImage.TYPE_INT_RGB);
				}
			} else {
				bufferedImage = copyImage(image, BufferedImage.TYPE_INT_RGB);
			}
		} else {
			bufferedImage = toBufferedImage(image);
		}
		return bufferedImage;
	}
584879
public boolean isSingleDataImage()
    {
    	if (this.getScreenField().getConverter() != null)
        	if (this.getScreenField().getConverter().getField() != null)
            	if (this.getScreenField().getConverter().getField().getComponent(1) == null)
    		return true;
    	return false;
    }