Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to capture screenshot of JotView ? currently black screen appears in screenshot #9

Closed
KrLikeblue opened this issue Dec 21, 2016 · 7 comments

Comments

@KrLikeblue
Copy link

KrLikeblue commented Dec 21, 2016

Hello,

I want to capture screenshot of JotView. I have added JotView’s instance in another UIView and I want to capture screenshot but I get black screen. I have used below code.

My app is in landscape mode

UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
[viewMain.layer renderInContext:UIGraphicsGetCurrentContext()];//JotView is subview inside viewMain
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Then I tried your below code for saving as UIImage, but it capture only half screen(not even half) and again my app is in landscape mode

[jotView exportImageTo:[self jotViewStateInkPath] andThumbnailTo:[self jotViewStateThumbPath] andStateTo:[self jotViewStatePlistPath] withThumbnailScale:1.0 onComplete:^(UIImage* ink, UIImage* thumb, JotViewImmutableState* state) {
    UIImageWriteToSavedPhotosAlbum(thumb, nil, nil, nil);
}];

Any idea how to capture screenshot of JotView ?

Thanks

@adamwulf
Copy link
Owner

Is the JotView full screen? or only part of the screen? the exportImageTo: method will export the entire JotView but won't export any surrounding views or subviews.

@KrLikeblue
Copy link
Author

KrLikeblue commented Dec 22, 2016

output

I am drawing everything in JotView and it covers 90% of the screen, but When i export image, then only half screen appears in screenshot. Please take note that my app is in landscape mode. half screen of JotView is cut in screenshot. I have attached screenshot, which is the output of exportImageTo: method.

Even in your example, it is not working. In your example just change orientation from portrait to landscape and run your example and then draw line in whole screen and then save. you will notice that right side part is not coming in screenshot

@KrLikeblue
Copy link
Author

I am trying to debug below function which is in JotView.m file

  • (void)exportToImageOnComplete:(void (^)(UIImage*))exportFinishBlock withScale:(CGFloat)outputScale

I think that function is taking screenshot of jotview, but I am not getting success

@KrLikeblue
Copy link
Author

KrLikeblue commented Dec 22, 2016

I also tried in your example by changing orientation of app from portrait to landscape but in your example it is also not working.
In your example just change orientation from portrait to landscape and run your example and then draw line in whole screen and then save. you will notice that right side part is not coming in screenshot

@KrLikeblue
Copy link
Author

Hello,

I solved the problem :)

I changed in #import "UIScreen+PortraitBounds.h" file

But I am getting another problem and I am posting another issue :)

Thanks

@adamwulf
Copy link
Owner

glad you got the other saving issue working! I'd be interested to see what you changed in UIScreen+PortraitBounds.h - if you submit a pull request that'd be awesome :)

@KrLikeblue
Copy link
Author

Sure. What I did is just comment below code in PortraitBounds.m file
// if (b.size.width > b.size.height) {
// CGFloat t = b.size.height;
// b.size.height = b.size.width;
// b.size.width = t;
// }

and it solved my problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants