我正在使用谷歌开源 java zxing 创建者:http : //code.google.com/p/zxing/
创建二维码。我已经准备好了一切并且正在工作(我正在使用 Coldfusion 加载 java 文件并将图像写入浏览器。)
我现在想要的是将黑色 QR 颜色更改为其他颜色。有没有简单的方法来做到这一点?
我需要编辑编码器 java 文件的反编译版本吗?或者有什么方法可以向编码例程添加颜色参数?
谢谢肖恩
我使用此代码生成我的二维码 ZXing.Net ( http://zxingnet.codeplex.com/ )
IBarcodeWriter writer = new BarcodeWriter { Format = BarcodeFormat.QR_CODE };
qrcode.Source = writer.Write(stringsecure.Text);
Run Code Online (Sandbox Code Playgroud)
但图像非常非常小..
如果可能,如何设置尺寸?
使用下面的代码时我得到了空值。我正在使用从 NuGet 下载的 ZXing dll
using ZXing.Common;
using ZXing.QrCode;
using ZXing.QrCode.Internal;
private void Decode()
{
Bitmap bitmap = new Bitmap(@"D:\Project\QRCodes\myqrcode.png");
try
{
MemoryStream memoryStream = new MemoryStream();
bitmap.Save(memoryStream, ImageFormat.Bmp);
byte[] byteArray = memoryStream.GetBuffer();
ZXing.LuminanceSource source = new RGBLuminanceSource(byteArray, bitmap.Width, bitmap.Height);
var binarizer = new HybridBinarizer(source);
var binBitmap = new BinaryBitmap(binarizer);
QRCodeReader qrCodeReader = new QRCodeReader();
Result str = qrCodeReader.decode(binBitmap);
}
catch{ }
}
Run Code Online (Sandbox Code Playgroud)
请给我一个解决方案 在此先感谢
我正在Android上做一个简单的应用程序,如下所示:
将QR码图像放入应用程序的Drawable文件中。通过ButtonClick,应将其解码并显示结果(使用Zxing库)。
我在Java上做了相同的应用程序(然后使用BufferedImageLuminanceSource类进行了解码)。
在我的android应用程序中,我使用了以下RGBLuminanceSource类:
LuminanceSource source = new RGBLuminanceSource(width, height, pixels)BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
Run Code Online (Sandbox Code Playgroud)
我在这里面临的问题是:图像必须太小而不能被android应用程序解码(而且我不得不尝试许多尺寸才能最终获得解码QR码图像的尺寸)。同时,使用BufferedImageLuminanceSourceJava应用程序可以轻松解码相同的图像,而无需调整大小。
如何避免此大小调整问题?
我目前正在使用 Xamarin Forms(共享)开发跨平台应用程序。我需要生成一个 EAN-13 条形码,我的代码在 Android 上运行良好,但在 iOS 上没有任何反应。我正在使用 ZXingBarcodeImageView。这是我的代码。
public class CardPage : ContentPage
{
ZXingBarcodeImageView barcode = new ZXingBarcodeImageView
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
};
barcode.BarcodeFormat = ZXing.BarcodeFormat.EAN_13;
barcode.BarcodeOptions.Height = 25;
barcode.BarcodeOptions.Width = 75;
barcode.BarcodeValue = "2800100028014";
Content = barcode;
}
Run Code Online (Sandbox Code Playgroud)
编辑
好的,所以我制作了特定于平台的代码来处理这个问题,直到问题得到解决。所以现在我的代码是这样的。
#if __IOS__
var writer = new ZXing.Mobile.BarcodeWriter
{
Format = ZXing.BarcodeFormat.EAN_13,
Options = new ZXing.Common.EncodingOptions
{
Width = 75,
Height = 25,
Margin = 30
}
};
var b = writer.Write("2800100028014");
Image m …Run Code Online (Sandbox Code Playgroud) 使用条码扫描仪、zxing 移动应用程序可以很好地读取下面的数据矩阵。但是,zxing java 库没有读取相同的内容。
我评论了一些图像转换代码。即使变换图像、旋转或缩放也无济于事。
理想情况下,我想以编程方式执行所有可能的图像预处理,直到解码。
移动应用程序使用的逻辑是什么,因为我从计算机屏幕扫描相同的图像并且它正在工作。
请在下面找到用于解码的代码。
public class BarcodeReader {
private static Map<DecodeHintType,Object> hintsMap;
public static void main(String...args){
BufferedImage before = null;
hintsMap = new EnumMap<DecodeHintType, Object>(DecodeHintType.class);
hintsMap.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
hintsMap.put(DecodeHintType.POSSIBLE_FORMATS, EnumSet.allOf(BarcodeFormat.class));
//hintsMap.put(DecodeHintType.PURE_BARCODE, Boolean.FALSE);
try
{
before = ImageIO.read(new File("C:/ocr.jpg"));
decode(before);
/* for(int i=1; i < 1000;i++){
AffineTransform transform = new AffineTransform();
double rad = (double)i/100;
double scale = (double)i/100;
System.out.println("rad "+scale);
//transform.rotate(rad, before.getWidth()/2, before.getHeight()/2);
transform.scale(scale, scale);
BufferedImage after = new BufferedImage(before.getWidth(), before.getHeight(), BufferedImage.TYPE_INT_ARGB);
AffineTransformOp op = new AffineTransformOp(transform, …Run Code Online (Sandbox Code Playgroud) 我正在尝试读取 USB 相机获取的图像中的二维码。在其他帖子中,我读到最好的开源库是 ZXing。
如果二维码来自数字生成的图像,则库工作正常,但如果二维码来自图像由相机获取的真实情况,则解码库会遇到一些困难。
所获取的图像会受到一些眩光、代码变形或对比度缓慢的干扰。
您知道一些参数可以更好地设置阅读器吗?或者在详细说明之前添加一些过滤器到图像中?
例如:
BarcodeReader reader = new BarcodeReader();
reader.AutoRotate = true;
reader.Options.TryHarder = true;
reader.Options.PureBarcode = false;
reader.Options.PossibleFormats = new List<BarcodeFormat>();
reader.Options.PossibleFormats.Add(BarcodeFormat.QR_CODE);
var result = reader.Decode(image);
Run Code Online (Sandbox Code Playgroud)
谢谢
我用结果处理程序实现了QR码扫描仪。扫描得很好。但是,第一次扫描完成后,相机卡住了。如何实现QR扫描代码,以使相机继续扫描而不会卡住?
我的代码如下所示:
public class SimpleScannerFragment extends Fragment implements ZXingScannerView.ResultHandler {
private ZXingScannerView mScannerView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.scannerview, null);
mScannerView = (ZXingScannerView) v.findViewById(R.id.scanner_view);
return v;
}
@Override
public void onResume() {
super.onResume();
mScannerView.startCamera();
mScannerView.setResultHandler(this);
}
@Override
public void handleResult(Result rawResult) {
ParsedResult parserdResult = ResultParser.parseResult(rawResult);
Toast.makeText(getActivity(), "Contents = " + rawResult.getText() + ", Format = " + rawResult.getBarcodeFormat().toString(), Toast.LENGTH_SHORT).show();
}
@Override
public void onPause() {
super.onPause();
mScannerView.stopCamera();
}
}
Run Code Online (Sandbox Code Playgroud) 我目前正面临一个 Duplicate 类RuntimeException。在我们当前的用例中,我们正在生产一个使用com.journeyapps:zxing-android-embedded. 我们的客户想要包含我们的工件,但他们RuntimeException在编译过程中得到了一个。发生异常是因为他们正在使用com.google.zxing当前与我们正在使用的 zxing 的 travelapps 端口冲突。Journeyapps 将 ZXing Android 应用程序移植为 Android 库项目,用于嵌入到 Android 应用程序中。
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Duplicate class com.google.zxing.client.android.camera.CameraConfigurationUtils found in modules android-core-3.3.0.jar (com.google.zxing:android-core:3.3.0) and classes.jar (com.journeyapps:zxing-android-embedded:3.6.0)
Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
at com.android.ide.common.workers.ExecutorServiceAdapter.await(ExecutorServiceAdapter.kt:56)
... 71 more
Caused by: java.lang.RuntimeException: Duplicate class com.google.zxing.client.android.camera.CameraConfigurationUtils found in modules android-core-3.3.0.jar (com.google.zxing:android-core:3.3.0) and classes.jar (com.journeyapps:zxing-android-embedded:3.6.0)
Go to the documentation to learn how to <a …Run Code Online (Sandbox Code Playgroud)