Closed y2kpr closed 7 years ago
That export size that your'e using is actually more pixels than is stored in the JotView.
The viewFramebuffer.initialViewport
is the physical pixel size of the backing textures used by the view. Since you're multiplying that by 1.6666, you're making the exported image have more pixels, it's just rendering the fewer pixels it has in its backing store to a larger canvas - you're not actually getting more pixels out.
Instead, I would use the non-modified code, and export with outputScale = screen scale. That'll render the maximum pixels that are stored in the JotView's backing textures. Then if you need a larger image for your views, you can either just use that UIImage in a larger UIImageView and have it set to Aspect Fill. Or you can use one of the methods in UIImage+Resize.h
to resize that output image to a larger size. That'd be a better way to scale up an image instead of asking the JotView to render to a larger canvas.
Resizing the UIImage by using your UIImage+Resize.h extension worked for me!
CGInterpolationQuality quality = kCGInterpolationNone; image = [image resizedImage:CGSizeMake(image.size.width*outputScale, image.size.height*outputScale) interpolationQuality: quality];
I tried using a bigger UIImageView and scale it that way but it didn't work with my setup.
Thanks for your help!
perfect - glad to hear it :)
For the image from exportToImage be the right size for my application, I had to make the following change in the function:
CGSize fullSize = viewFramebuffer.initialViewport; CGSize exportSize = CGSizeMake(fullSize.width * outputScale, fullSize.height * outputScale);
where 'outputScale = 1.66667' (this is a requirement for my unique layout of views)This works well for iPads of all sizes except for the 12inch iPad Pro. It is failing at:
GLuint exportFramebuffer = [secondSubContext generateFramebufferWithTextureBacking:canvasTexture]; // by default, it's unbound after generating, so bind it [secondSubContext bindFramebuffer:exportFramebuffer]
where it is unable to create the Framebuffer because it is too big. exportSize in this case is (width = 3413.33, height = 4406.66)I am trying to figure out a way around it. You mentioned an option in #17 to create a texture of an acceptable size and then transform it to the required size. Is there a similar solution I can look into for exportFrameBuffer?
Any other approaches are much appreciated too.