Derek
unread,Oct 21, 2011, 2:14:04 PM10/21/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to zxing
I Have seen some people looking for The oned IOS ZXING SCANNER for
Portrait mode.
If you add this code to ZXingWidgetController controller and comment
out //self.oneDMode = isOneDModeEnabled; and then adding the red line
to the view in the overlay view it works well.
CGRect cropRect = [overlayView cropRect];
/*
if (oneDMode) {
// let's just give the decoder a vertical band right above the red
line
cropRect.origin.x = cropRect.origin.x + (cropRect.size.width / 2) -
(ONE_D_BAND_HEIGHT + 1);
cropRect.size.width = ONE_D_BAND_HEIGHT;
// do a rotate
CGImageRef croppedImg = CGImageCreateWithImageInRect(capture,
cropRect);
capture = [self CGImageRotated90:croppedImg];
capture = [self CGImageRotated180:capture];
// UIImageWriteToSavedPhotosAlbum([UIImage
imageWithCGImage:capture], nil, nil, nil);
CGImageRelease(croppedImg);
cropRect.origin.x = 0.0;
cropRect.origin.y = 0.0;
cropRect.size.width = CGImageGetWidth(capture);
cropRect.size.height = CGImageGetHeight(capture);
}
*/
// N.B.
// - Won't work if the overlay becomes uncentered ...
// - iOS always takes videos in landscape
// - images are always 4x3; device is not
// - iOS uses virtual pixels for non-image stuff
{
float height = CGImageGetHeight(capture);
float width = CGImageGetWidth(capture);
CGRect screen = UIScreen.mainScreen.bounds;
float tmp = screen.size.width;
screen.size.width = screen.size.height;;
screen.size.height = tmp;
cropRect.origin.x = (width-cropRect.size.width)/2;
cropRect.origin.y = (height-cropRect.size.height)/2;
}
CGImageRef newImage = CGImageCreateWithImageInRect(capture,
cropRect);
CGImageRelease(capture);
//************NEW CODE****************//
int backCameraImageOrientation = UIImageOrientationRight;
UIImage *scrn = [[UIImage alloc] initWithCGImage:newImage scale:
(CGFloat)1.0 orientation:backCameraImageOrientation];
//************NEW CODE****************//
//************COMMENT OUT***************//
//UIImage *scrn = [[UIImage alloc] initWithCGImage:newImage];
CGImageRelease(newImage);
Decoder *d = [[Decoder alloc] init];
d.readers = readers;
d.delegate = self;
cropRect.origin.x = 0.0;
cropRect.origin.y = 0.0;
decoding = [d decodeImage:scrn cropRect:cropRect] == YES ? NO : YES;
[d release];
[scrn release];
}