Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Hello there :)

I am using this code to overlay a custom size video preview window to a
Quartz2D screen:

Code:
    [self setCaptureManager:[[CaptureSessionManager alloc] init]];
	[[self captureManager] addVideoInput];
	[[self captureManager] addVideoPreviewLayer];
	//CGRect layerRect = [[[self view] layer] bounds];
    CGRect layerRect = CGRectMake(0,360,320,120);    
	[[[self captureManager] previewLayer] setBounds:layerRect];
	[[[self captureManager] previewLayer] setPosition:CGPointMake(CGRectGetMidX(layerRect),
                                                            CGRectGetMidY(layerRect))];
	[[[self view] layer] addSublayer:[[self captureManager] previewLayer]];
	[[captureManager captureSession] startRunning];

and also this code, to capture screenshots:
Code:
          //  if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
          //  UIGraphicsBeginImageContextWithOptions(self.window.bounds.size, NO, [UIScreen mainScreen].scale);
          //  } else {
          //  UIGraphicsBeginImageContext(self.window.bounds.size);
          //  }
          //  [self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
          //  UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
          //  UIGraphicsEndImageContext();
          //  UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

Problem is, when the live camera feed is on the screen, but it is not present
in the screenshots when I check them in the Camera Roll.
I want the camera preview to be captured in the shots.
Any ideas what I'm doing wrong?
Cheers, Art.

----------

I'm a beginner, but it might be that the camera feed is happening in a different view or something. The camera code is in the view controller.m file,
while the snapshot code is in the same file all the drawing is done "Draw2D.m".
 
Hello there :)

I am using this code to overlay a custom size video preview window to a
Quartz2D screen:

Code:
    [self setCaptureManager:[[CaptureSessionManager alloc] init]];
	[[self captureManager] addVideoInput];
	[[self captureManager] addVideoPreviewLayer];
	//CGRect layerRect = [[[self view] layer] bounds];
    CGRect layerRect = CGRectMake(0,360,320,120);    
	[[[self captureManager] previewLayer] setBounds:layerRect];
	[[[self captureManager] previewLayer] setPosition:CGPointMake(CGRectGetMidX(layerRect),
                                                            CGRectGetMidY(layerRect))];
	[[[self view] layer] addSublayer:[[self captureManager] previewLayer]];
	[[captureManager captureSession] startRunning];

and also this code, to capture screenshots:
Code:
          //  if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
          //  UIGraphicsBeginImageContextWithOptions(self.window.bounds.size, NO, [UIScreen mainScreen].scale);
          //  } else {
          //  UIGraphicsBeginImageContext(self.window.bounds.size);
          //  }
          //  [self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
          //  UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
          //  UIGraphicsEndImageContext();
          //  UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

Problem is, when the live camera feed is on the screen, but it is not present
in the screenshots when I check them in the Camera Roll.
I want the camera preview to be captured in the shots.
Any ideas what I'm doing wrong?
Cheers, Art.

----------

I'm a beginner, but it might be that the camera feed is happening in a different view or something. The camera code is in the view controller.m file,
while the snapshot code is in the same file all the drawing is done "Draw2D.m".


Under the covers, video is displayed to a video preview using a special type of CALAyer. Certain kinds of layers, like OpenGL layers, can't be captured with the usual
renderInContext call. There must be a way to do it, since the system screen capture function (triggered by pressing the home button and power button at the same time) is able to, but I don't know how. Maybe somebody else knows the trick and can enlighten us?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.