UIImagePNGR message returns zero after CIFilter

Launching a problem with a PNG view for UIImage after rotating it using CIAffineTransform. Firstly, I have a category on UIImage that rotates the image 90 degrees clockwise. It seems to work correctly when I display a rotated image in a UIImageView.

-(UIImage *)cwRotatedRepresentation
{
    // Not very precise, stop yelling at me.
    CGAffineTransform xfrm=CGAffineTransformMakeRotation(-(6.28 / 4.0));
    CIContext *context=[CIContext contextWithOptions:nil];
    CIImage *inputImage=[CIImage imageWithCGImage:self.CGImage];
    CIFilter *filter=[CIFilter filterWithName:@"CIAffineTransform"];
    [filter setValue:inputImage forKey:@"inputImage"];
    [filter setValue:[NSValue valueWithBytes:&xfrm objCType:@encode(CGAffineTransform)] forKey:@"inputTransform"];

    CIImage *result=[filter valueForKey:@"outputImage"];
    CGImageRef cgImage=[context createCGImage:result fromRect:[inputImage extent]];

    return [[UIImage alloc] initWithCIImage:result];

}

However, when I try to actually get the PNG for the newly rotated image, the UIImagePNGR view returns zero.

-(NSData *)getPNG
{
    UIImage *myImg=[UIImage imageNamed:@"canada"];
    myImg=[myImg cwRotatedRepresentation];
    NSData *d=UIImagePNGRepresentation(myImg);

    // d == nil :(
    return d;
}

Is the main image a rewriting of the PNG headers or something else? Is there a way around this behavior or the best way to achieve the desired result of a PNG representation of a UIImage rotated 90 degrees clockwise?

+3
source share
1

, -M_PI_4 , :)

, , , , [ ] [inputImage extent], .

, UIImagePNGR. ... CGImage, CIImage UIImage, , initWithCGImage .

+4

All Articles