0

Now, I can save texture by using glReadPixels() to read the data in framebuffer (FBO). However, I faced two problems.

(1) In order to keep the saved image quality, the dimension would be larger than GL_MAX_TEXTURE_SIZE (most devices is 4096). If I created big texture (ex: 4160x3120), I got GL_FRAMEBUFFER_UNSUPPORTED error when calling glCheckFramebufferStatus()....

(2) If I created small texture(ex: 3648x2736), everything works except glReadPixels() will be very slow....

So back to my question, is it possible to overcome max texture size limitation and save it efficiently? Thanks.

Justin
  • 115
  • 3
  • 9
  • 1
    An uncompressed RGBA 4160x3120px texture would be like 50MB, how fast do you expect that to be on a device? – aacotroneo Sep 07 '13 at 00:20
  • Have you tried rendering to texture. You would still need to copy the image over, but you could swap out the buffer and launch a background thread, or more likely an Async Task, to handle in background. – HPP Jan 15 '14 at 21:51

1 Answers1

0

1) No, it's not possible unless you want to somehow process the image in multiple, smaller pieces. I don't remember seeing a device with bigger GL_MAX_TEXTURE_SIZE than that, so you won't be able to create a FBO bigger than that.

EDIT: Actually, there is quite a number of devices where the maximum texture size is 2048, although 4096 is typical in most recent devices.

2) You should understand that that is already a very large texture, not a small one, so glReadPixels() will be slow. I'm not sure there's a way around this on Android.

Arttu Peltonen
  • 1,250
  • 14
  • 18
  • I googled all the day. For first question, it seems no solution like you say. For second question, I found glReadPixels() with GL_BGRA and Pixel Buffer Object (PBO) seems can give performance boost. Arttu Peltonan, did you try this solution before? – Justin Sep 06 '13 at 10:37
  • Unfortunately PBOs are not available in OpenGL ES 2.0, so that's not an option for you. They will be available in the future with OpenGL ES 3.0, though. – Arttu Peltonen Sep 06 '13 at 11:24
  • Thanks for your reply. But it is really frustrating ... It is hard to believe there is no way to save large texture fast :( – Justin Sep 06 '13 at 15:48
  • I saw camera [Live Filters](http://www.samsung.com/us/article/11-camera-tips-for-your-galaxy-s-4) on Samsung Galaxy S4. How to know if this feature is implemented by OpenGL ES or hardware? If the answer is OpenGL ES, it saves large image really fast.... – Justin Sep 08 '13 at 13:05
  • I haven't seen that in action, but I imagine the live filter is applied to the low resolution "live" image that doesn't get saved. When you take the photo, it probably takes some time applying the filter and saving the hi-res image. You wouldn't notice the delay as it's done in the background. – Arttu Peltonen Sep 08 '13 at 21:21