android


Capture rendered image from OpenGL in Android and save it to a JPEG


I have a problem with saving a rendered image to my gallery as a jpeg file. I'm applying a photo effect from the android EffectFactory an render it on a glSurfaceView. Since now i#ve managed to take a screenshot of the image from my glSurfaceView. The problem is that i don't want to take just a screenshot because then the image looses much of its original size and quality because when the original image is e.g. 1944 × 2592 but the device screen is only 768 × 1038 in my case its not the original anymore. The other problem is that when i take a screenshot i have also the black parts of my glSurfacView where the image isn't displayed on my saved image because the image doens't fill the whole glSurfaceView in many cases. Since now i tried it with this code:
private Bitmap createBitmapFromGLSurface(int x, int y, int w, int h, GL10 gl)
throws OutOfMemoryError {
int bitmapBuffer[] = new int[w * h];
int bitmapSource[] = new int[w * h];
IntBuffer intBuffer = IntBuffer.wrap(bitmapBuffer);
intBuffer.position(0);
try {
gl.glReadPixels(x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, intBuffer);
int offset1, offset2;
for (int i = 0; i < h; i++) {
offset1 = i * w;
offset2 = (h - i - 1) * w;
for (int j = 0; j < w; j++) {
int texturePixel = bitmapBuffer[offset1 + j];
int blue = (texturePixel >> 16) & 0xff;
int red = (texturePixel << 16) & 0x00ff0000;
int pixel = (texturePixel & 0xff00ff00) | red | blue;
bitmapSource[offset2 + j] = pixel;
}
}
} catch (GLException e) {
return null;
}
return Bitmap.createBitmap(bitmapSource, w, h, Bitmap.Config.ARGB_8888);
}
Can anyone please tell me how i get a bitmap/jpeg from the rendered image in the original size of the image? Is it even possible with gl.glReadPixels?? Or can i get the image directly from a framebuffer somehow? Its important that i can get the image in its original size.

Related Links

Codename one can't get correct storage path on Android
Android storage permission in Marshmallow
Change ListView item on seekbar Value change
White Loading Screen when Login With Facebook with Facebook sdk: 4.11.0
Android App hangs without ANR
Attempt to invoke virtual method boolean com.google.android.gms.common.ConnectionResult.isSuccess()' on a null object reference
What is difference between 'new Fragment()' and 'Fragment.getInstance()' in Android?
how to use getForeground and setForeground on API below 23 [duplicate]
External Libraries (i.e. google play services), multiple versions of same library
Optimizing Canvas in Android app
Failing to make call to API from android client
Using wpa_supplicant on Android
Add restore purchase in-app billing “premium”
how to download . txt or .pdf file from google drive that is picked using intent chooser
Android Splash screen does not display
Added fragments to viewpager are empty

Categories

HOME
algorithm
beautifulsoup
xml
design-patterns
codenvy
nvd3.js
formal-languages
rsa
mysql-workbench
shiro
rendering
vxml
bookmarks
watson-conversation
mod-security
resultset
jsonpath
azure-powershell
easyphp
springfox
libigl
question2answer
mongoid6
scriptella
xcode-ui-testing
moses
android-maps
underscore.js
apktool
mobx
gnat-gps
jwplayer6
searchkit
swagger-php
railstutorial.org
health-monitoring
css-position
unordered-map
visa
levenshtein-distance
http-request
angular-http
signal-strength
facebook-social-plugins
sonarlint-eclipse
dotnet-httpclient
hammer.js
fclose
aquamacs
spring-data-couchbase
check-mk
lsyncd
mathcad
bootstrap-tags-input
sandcastle
usart
cudd
flex4.6
dup
tooleap
appscale
gcloud-ruby
boost-serialization
libav
terracotta
morton-number
poppler
infosphere-spl
filesplitting
paw
imagefilter
human-computer-interface
tweenlite
cuba
verold
live555
winginx
jquery-slider
spring-remoting
dsym
gwt-openlayers
mysql-error-1044
hidapi
kogrid
flex++
scmmanager
android-icons
traceability
garbage
ilasm
convention
pylucene
uipagecontrol
nhprof
spread
product-management
ifilter

Resources

Encrypt Message