vianziro / droidar

Automatically exported from code.google.com/p/droidar
0 stars 0 forks source link

Screenshot? #15

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi all,

I'm currently trying to add a screen-shot function to DroidAR. However I only 
have a black image.

I added my code in the onDrawFrame function but it's maybe not the right 
location for it.

Please find enclosed, my GLRenderer.java override. I know that the call to this 
feature is working because I can get an image (but a black...).

Thanks,

Hidden

Original issue reported on code.google.com by dev.hidd...@gmail.com on 22 Sep 2011 at 1:52

Attachments:

GoogleCodeExporter commented 8 years ago
first try to read the pixels after creating the scene, so after all the objects 
are traversed. so just put it at the end of the draw method. and the difficult 
part will be to merge the opengl bitmap with the camera image;)

maybe you should move your code to a seperate class otherwise you might get 
problems when the renderer class is changed.

Original comment by simon.heinen on 22 Sep 2011 at 3:19

GoogleCodeExporter commented 8 years ago
Hi Simon,

Thank you for your answer. Actually my first attempt was putting the code at 
the end of the onDrawFrame method --> same result.

Do you mean that the the opengl bitmap is an overlay above the camera view? I 
thought you were merging all those elements... (it explains my black image).

Original comment by dev.hidd...@gmail.com on 22 Sep 2011 at 3:38

GoogleCodeExporter commented 8 years ago
jep they are two separate overlays (the camerapreview and the opengl surface 
view) so currently you are only getting the information from the opengl view. 

im using glReadPixel in a similar way in the ObjectPicker ( 
http://code.google.com/p/droidar/source/browse/trunk/droidar/DroidAR/src/gl/Obje
ctPicker.java ) class:

                ByteBuffer pixelBuffer = ByteBuffer.allocateDirect(4);
                pixelBuffer.order(ByteOrder.nativeOrder());
                gl.glReadPixels(x, y, 1, 1, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE,
                                pixelBuffer);
                byte b[] = new byte[4];
                pixelBuffer.get(b);

so it should be possible to read all pixels on the screen this way (im not sure 
if its the best way, sounds a little inefficient;). just make sure that you do 
this after rendering all the objects in the elementsToRender list

the merging with the camera preview should be possible to if you write some 
little helper methods to manage the transparency in the opengl view. i'm 
currently busy learning for 2 exams but i should have some time in about one 
week, you can post your progress here till then.

Original comment by simon.heinen on 22 Sep 2011 at 6:21

GoogleCodeExporter commented 8 years ago
Thanks simon! Actually I also quite busy right now, but I'll try to have a look 
at it later. I'll keep you posted!

Original comment by dev.hidd...@gmail.com on 23 Sep 2011 at 7:57

GoogleCodeExporter commented 8 years ago
have this been successful? thank you I also want to capture an image with the 
openGL bitmaps

Original comment by dwayne.b...@gmail.com on 3 Oct 2012 at 2:56

GoogleCodeExporter commented 8 years ago
this framework is so nice,but i can't use it taking pictures.who can help me?

Original comment by liuting....@gmail.com on 6 Nov 2014 at 1:58