相关疑难解决方法(0)

ios使用AVFramework捕获图像

我正在使用此代码捕获图像

#pragma mark - image capture

// Create and configure a capture session and start it running
- (void)setupCaptureSession 
{
    NSError *error = nil;

    // Create the session
    AVCaptureSession *session = [[AVCaptureSession alloc] init];

    // Configure the session to produce lower resolution video frames, if your 
    // processing algorithm can cope. We'll specify medium quality for the
    // chosen device.
    session.sessionPreset = AVCaptureSessionPresetMedium;

    // Find a suitable AVCaptureDevice
    AVCaptureDevice *device = [AVCaptureDevice
                           defaultDeviceWithMediaType:AVMediaTypeVideo];

    // Create a device input with the …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c avfoundation ios

41
推荐指数
3
解决办法
3万
查看次数

从旋转的UIImageView创建UIImage

我有一个UIImageView,里面有一个图像.我通过将UIImageView的transform属性设置为CGAffineTransformMakeRotation(angle),在显示之前旋转了图像,其中angle是以弧度表示的角度.

我希望能够创建另一个UIImage,它对应于我在视图中可以看到的旋转版本.

我几乎在那里,通过旋转图像上下文我得到一个旋转的图像:

- (UIImage *) rotatedImageFromImageView: (UIImageView *) imageView
{
    UIImage *rotatedImage;

    // Get image width, height of the bounding rectangle
    CGRect boundingRect = [self getBoundingRectAfterRotation: imageView.bounds byAngle:angle];

    // Create a graphics context the size of the bounding rectangle
    UIGraphicsBeginImageContext(boundingRect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();

    // Rotate and translate the context
    CGAffineTransform ourTransform = CGAffineTransformIdentity;
    ourTransform = CGAffineTransformConcat(ourTransform, CGAffineTransformMakeRotation(angle));

    CGContextConcatCTM(context, ourTransform);

    // Draw the image into the context
    CGContextDrawImage(context, CGRectMake(0, 0, imageView.image.size.width, imageView.image.size.height), imageView.image.CGImage);

    // Get an image from the …
Run Code Online (Sandbox Code Playgroud)

rotation uiimageview uiimage graphicscontext

15
推荐指数
1
解决办法
1万
查看次数