0

今日は非常に多くの質問をお詫びします。金曜日に死んだ脳の症状が現れました。

私はCICropフィルターを持っています:

[crop setValue:beginImage forKey:@"inputImage"];  //give the crop filter the beginImage
    [crop setValue:[CIVector vectorWithX:0.0f Y:0.0f Z:_exportSize W:_exportSize] forKey:@"inputRectangle"];  //give the filter the size to crop to
    croppedImage = [crop valueForKey:@"outputImage"];  //set the output image, note it's still a CIImage at this point

悲しいことに、それは機能していません。切り抜く画像は0x0ピクセルになります。_exportSize(CGFloat)のクイックNSLogは、1024であることを示していますが、ログには、トリミング後の画像が0x0であることが示されています。理由がわからない。

このコードは以前は機能していました。唯一の違いは、私がUIImageをCIImagesではなくトリミングしていたことだと思います。トリミング後に他のCoreImageを実行する予定なので、変換する必要はありません。

私が言うように、_exportSizeはCGFloat_exportSizeです。ログに記録すると、1024.0000であることがわかります。

何か案は?

乾杯。

4

2 に答える 2

2

結局、私はトリミングのためにCore Imageをあきらめ、代わりにこれを使用しました。

    -(UIImage *)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect
{
    CGImageRef imageRef = CGImageCreateWithImageInRect([imageToCrop CGImage], rect);

    UIImage *cropped = [UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);

    return cropped;
}
于 2012-05-12T15:06:54.920 に答える
0

試す

[crop setValue:[CIVector vectorWithX:0.0f Y:0.0f Z:_exportSize.width W:_exportSize.height] forKey:@"inputRectangle"];

それ以外の

[crop setValue:[CIVector vectorWithX:0.0f Y:0.0f Z:_exportSize W:_exportSize] forKey:@"inputRectangle"];

ヘルプURLhttp: //gigliwood.com/weblog/Cocoa/Core_Image,_part_2.html

Zは幅、
Wは高さを想定しています

それが役に立てば幸い。

于 2012-05-11T15:33:29.080 に答える