6

私はQRCodeをデコードするためにzxingを使用しています。また、エンコーダーが機能するようになり、エンコードされたデータを含むQRCodeを作成できるようになりました。

このQRCOdeデータをpng画像に変換する方法を誰かが知っているかどうか尋ねています。

4

5 に答える 5

3

アプリにオンライン アクセスがある場合は、http: //www.tag.cx/qr-codes/ のようなものを使用できます。

多くのユーザーは、iPhone で QR コードやその他のコードをプログラムでエンコードする方法を探しています。このZxingスレッドで説明されているように、これらの機能はまだ Android から iPhone に移植されていません。 iphone#aba6f4545c5c3583

詳細については、この質問を参照してください: iPhone および Android で 2D バーコード (QR コード、データ マトリックス、PDF417 など) を生成する

こちらのプラグインを使用して、Phonegap を使用して QR バーコードをエンコードできます。指示に従ってください。成功するはずです。

Javascript はシンプルで、 https://github.com/phonegap/phonegap-plugins/からそのまま取得できます。

   window.plugins.barcodeScanner.encode(BarcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com", function(success) {
    alert("encode success: " + success);
  }, function(fail) {
    alert("encoding failed: " + fail);
  }, {yesString: "Install"}
);
于 2011-05-22T10:23:16.893 に答える
0

phonegap を使用していてオフライン サポートが必要な場合は、jquery qrcodeが役立つ可能性があります。

于 2011-12-20T12:43:16.687 に答える
0

編集済みこの投稿には同様の質問があります。この回答にリンクしました。

この単純なコードを使用して、プロジェクトの 1 つで QRCode をエンコードしました。以下を使用できます。

//
//  QRCodeGeneratorViewController.h
//  
//
//  Created by Jhoney Lopes on 28/09/14.
//  Copyright (c) 2014 Jhoney Lopes. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface QRCodeGeneratorViewController : UIViewController

@end

実装.m

//
//  QRCodeGeneratorViewController.m
// 
//
//  Created by Jhoney Lopes on 28/09/14.
//  Copyright (c) 2014 Jhoney Lopes. All rights reserved.
//

#import "QRCodeGeneratorViewController.h"

@interface QRCodeGeneratorViewController ()
@property (strong, nonatomic) IBOutlet UIImageView *qrImageView;
@end

@implementation QRCodeGeneratorViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self generateTheQRCodeImageFromDataBaseInfo:@"TEXT-WHAT-YOU-WANT-TO-CONVERT-IN-QRCODE"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - QR Code Generator

- (CIImage *)createQRForString:(NSString *)qrString
{
    // Need to convert the string to a UTF-8 encoded NSData object
    NSData *stringData = [qrString dataUsingEncoding:NSUTF8StringEncoding];

    // Create the filter
    CIFilter *qrFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
    // Set the message content and error-correction level
    [qrFilter setValue:stringData forKey:@"inputMessage"];
    [qrFilter setValue:@"H" forKey:@"inputCorrectionLevel"];

    // Send the image back
    return qrFilter.outputImage;
}

- (UIImage *)createNonInterpolatedUIImageFromCIImage:(CIImage *)image withScale:(CGFloat)scale
{
    // Render the CIImage into a CGImage
    CGImageRef cgImage = [[CIContext contextWithOptions:nil] createCGImage:image fromRect:image.extent];

    // Now we'll rescale using CoreGraphics
    UIGraphicsBeginImageContext(CGSizeMake(image.extent.size.width * scale, image.extent.size.width * scale));
    CGContextRef context = UIGraphicsGetCurrentContext();
    // We don't want to interpolate (since we've got a pixel-correct image)
    CGContextSetInterpolationQuality(context, kCGInterpolationNone);
    CGContextDrawImage(context, CGContextGetClipBoundingBox(context), cgImage);
    // Get the image out
    UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
    // Tidy up
    UIGraphicsEndImageContext();
    CGImageRelease(cgImage);
    return scaledImage;
}

- (void)generateTheQRCodeImageFromDataBaseInfo:(NSString *)jsonString {

    // Get the string
    NSString *stringToEncode = jsonString;

    // Generate the image
    CIImage *qrCode = [self createQRForString:stringToEncode];

    // Convert to an UIImage
    UIImage *qrCodeImg = [self createNonInterpolatedUIImageFromCIImage:qrCode withScale:2*[[UIScreen mainScreen] scale]];

    // And push the image on to the screen
    self.qrImageView.image = qrCodeImg;
}
于 2016-04-29T09:42:40.630 に答える
0

このGithub リンクから QR コード ジェネレーターのサンプル コードをダウンロードしてください。よりシンプルで簡単です。そのサンプル プロジェクトで使用されたリソース ファイルをプロジェクトに追加します。

で生成された QR コードを表示するだけの場合UIImageviewは、サンプル プロジェクトのコードを直接使用できます。

また

QRコードを含むpngファイルが必要な場合はNSData、の画像から取得し、pngファイルUIImageviewに変換しNSDataて使用できることを意味します。

于 2013-09-24T06:00:32.287 に答える
0

psytec エンコーダー (http://groups.google.com/group/zxing/msg/27e421daeb510d0f) はうまく機能します。制作で使用しています。libpng のようなものを使用して、それが生成するビット配列から png に変換するのは比較的簡単です。デバイスでは、生成されたビット配列を調べて、CG コンテキストに直接描画します。

于 2011-05-29T22:56:03.233 に答える