gpt4 book ai didi

iphone - 如何使用 Zbar 裁剪扫描的条形码?

转载 作者:行者123 更新时间:2023-12-03 21:04:31 29 4
gpt4 key购买 nike

我正在使用下面的代码使用 Zbar sdk 扫描条形码。

我浏览related question of stackoverflow但这个答案对我不起作用。

到目前为止我已经完成了,

-(IBAction)btnCLick
{
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;

ZBarImageScanner *scanner = reader.scanner;
[scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];


[self presentModalViewController:reader animated:YES];
[reader release];
}

- (void) imagePickerController: (UIImagePickerController*) aReader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{

id<NSFastEnumeration> results = [info objectForKey:ZBarReaderControllerResults];

ZBarSymbol *symbol = nil;

for(symbol in results)
{
break;
}
txtViewResult.text = symbol.data;
imgViewResult.image = [info objectForKey:UIImagePickerControllerOriginalImage];

[self advanceCrop:imgViewResult];
[reader dismissModalViewControllerAnimated:YES];

}

advanceCrop方法正在做裁剪,

-(void)advanceCrop:(UIImageView *)aimgViewResult
{


CGRect r =CGRectMake(50/426., 1-(20+250)/320., 150/426., 250/320.);
reader.scanCrop = r;


r = CGRectMake(20, 50, 250, 150);

imgViewResult.frame = r;
NSLog(@"imgview height:%f width:%f",imgViewResult.frame.size.height, imgViewResult.frame.size.width);


/*

// CGRect r = CGRectFromString(lblImage.text);
CGRect r = CGRectMake(50/426., 1-(20+250)/320., 150/426., 250/320.);

reader.scanCrop = r;
NSLog(@"r: x:%f y:%f height :%f width:%f",r.origin.x ,r.origin.y ,r.size.height , r.size.width);

// aLblImage.text = NSStringFromCGRect(r);

r.origin.x *= 426;
r.origin.y *= 320;
r.size.width *= 426;
r.size.height *= 320;

imgViewResult.frame = r;
NSLog(@"imgview height:%f width:%f",imgViewResult.frame.size.height, imgViewResult.frame.size.width);
*/
}

如果我得到如下图像并且想要裁剪它,可以使用 Zbar 吗?

enter image description here

最佳答案

试试这个。如果CGRect = CGRectMake(x, y, width, height); ,然后执行:

float A = y / readerView.bounds.size.height;   
float B = 1 - (x + width) / readerView.bounds.size.width;
float C = (y + height) / readerView.bounds.size.height;
float D = 1 - x / readerView.bounds.size.width;;
CGRectMake( A, B, C, D );

关于iphone - 如何使用 Zbar 裁剪扫描的条形码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8726370/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com