adamwulf / JotUI

OpenGL based drawing view built for and used by Loose Leaf for iPad
http://getlooseleaf.com/opensource/
MIT License
268 stars 28 forks source link

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

Closed KrLikeblue closed 7 years ago

KrLikeblue commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago
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 commented 7 years ago

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

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

KrLikeblue commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 :)