方法" setImage:"在GPUImageView上找不到

时间:2014-05-17 14:55:38

标签: ios uiimageview gpuimage

我将在GPUImageView上设置图像。

UIImage *adjustedImage = [lookupFilter imageFromCurrentFramebufferWithOrientation:0];
[self->_imgView setImage:adjustedImage];

GPUImageView类不是setImage:方法。 有人可以发布setImage:的整个方法或者告诉我如何找到这种方法吗? 我以为我可以从UIImageView.m文件中复制该方法并将其粘贴到GPUImageView.m文件中。但我找不到UIImageView.m文件。

GPUImageView.h

#import <UIKit/UIKit.h>
#import "GPUImageContext.h"

typedef enum {
    kGPUImageFillModeStretch,                       // Stretch to fill the full view, which may distort the image outside of its normal aspect ratio
    kGPUImageFillModePreserveAspectRatio,           // Maintains the aspect ratio of the source image, adding bars of the specified background color
    kGPUImageFillModePreserveAspectRatioAndFill     // Maintains the aspect ratio of the source image, zooming in on its center to fill the view
} GPUImageFillModeType; 

/**
 UIView subclass to use as an endpoint for displaying GPUImage outputs
 */
@interface GPUImageView : UIView <GPUImageInput>
{
    GPUImageRotationMode inputRotation;
}

/** The fill mode dictates how images are fit in the view, with the default being kGPUImageFillModePreserveAspectRatio
 */
@property(readwrite, nonatomic) GPUImageFillModeType fillMode;

/** This calculates the current display size, in pixels, taking into account Retina scaling factors
 */
@property(readonly, nonatomic) CGSize sizeInPixels;

@property(nonatomic) BOOL enabled;

/** Handling fill mode

 @param redComponent Red component for background color
 @param greenComponent Green component for background color
 @param blueComponent Blue component for background color
 @param alphaComponent Alpha component for background color
 */
- (void)setBackgroundColorRed:(GLfloat)redComponent green:(GLfloat)greenComponent blue:(GLfloat)blueComponent alpha:(GLfloat)alphaComponent;

- (void)setCurrentlyReceivingMonochromeInput:(BOOL)newValue;

@end

2 个答案:

答案 0 :(得分:5)

将此代码用于GPUIamge我希望这有用

GPUImageView *gpImageView = [[GPUImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIImage * image = [UIImage imageNamed:@"image"];
GPUImagePicture * inputImage = [[GPUImagePicture alloc] initWithImage:image];
[inputImage processImage];
[inputImage addTarget: gpImageView];
[self.view addSubview:gpImageView];

答案 1 :(得分:5)

GPUImageView不是UIImageView的子类。它没有-setImage:方法。你没有为它设置UIImages。它不会那样工作。

GPUImageView是您的过滤器链的目标。要在其中显示图像,可以将GPUImageView设置为GPUImagePicture实例或其后面的过滤器(如果要显示过滤后的输出)的目标。您没有将UIImage设置为该视图的内容。同样,它不是UIImageView。

有很多关于如何将GPUImageView与GPUImage附带的示例一起使用的示例。我还在我的项目文档中解释了它是如何工作的。请在继续进行之前先审核一下。