"Printing with Zebra ZQ520 “rotation causing issues”

M Mark Kilburn 3 years 7 months ago
6 0 0

I hope someone can help me
I have a zebra ZQ520 and i am trying to print a test tag from it
The actual tag is 832dots*400dots (104mm*50mm)
The script below will print ok - although the whole image needs to be rotated 180 to align with markings (white sections) on the label.
When "UIImage *img1 = [self rotateImage:image byDegree:90]" is changed to "[self rotateImage:image byDegree:270]"
The whole thing get corrupted or go strange.. please help find the error in this code This at 90 prints ok but needs to be rotated 180 degrees
This at 270print is now squashed to the top and not rotated as you can see the second image is also now filled with black.. i have no idea where this data is coming from in the code.
hopefully someone has an idea

    -(BOOL) sendImageToPrinter:(UIImage *)image {        UIImage *img1 = [self rotateImage:image byDegree:90];      if(!self.connectivityViewController.isBluetoothSelected) {        self.ipAddressText = [self.connectivityViewController.ipDnsTextField text];        self.portAsStringText = [self.connectivityViewController.portTextField text];    }    [self setZebraPrinter];    BOOL success = NO;        if(self.printer != nil) {        id graphicsUtil = [self.printer getGraphicsUtil];                NSError *error = nil;        if (self.isStoreSelected) {        success = [graphicsUtil storeImage:self.pathOnPrinterText withImage:[img1 CGImage] withWidth:831 andWithHeight:400 error:&error];        } else {            success = [graphicsUtil printImage:[img1 CGImage] atX:0 atY:0 withWidth:831 withHeight:400 andIsInsideFormat:NO error:&error];        }    }    return success;}- (UIImage *)rotateImage:(UIImage*)image byDegree:(CGFloat)degrees{    UIView *rotatedViewBox = [[UIView alloc] initWithFrame:CGRectMake(0,0,image.size.width, image.size.height)];    CGAffineTransform t = CGAffineTransformMakeRotation(DegreesToRadians(degrees));    rotatedViewBox.transform = t;    CGSize rotatedSize = rotatedViewBox.frame.size;        UIGraphicsBeginImageContext(rotatedSize);    CGContextRef bitmap = UIGraphicsGetCurrentContext();        CGContextTranslateCTM(bitmap, rotatedSize.width, rotatedSize.height);        CGContextRotateCTM(bitmap, DegreesToRadians(degrees));        CGContextScaleCTM(bitmap, 1.0, -1.0);    CGContextDrawImage(bitmap, CGRectMake(-image.size.width, -image.size.height, image.size.width, image.size.height), [image CGImage]);        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();    UIGraphicsEndImageContext();    return newImage;    }Please assist

CONTACT
Can’t find what you’re looking for?