Screenshot of surface view with a component on it

I am creating an app which allows the user to take a photo with a map superimposed on it. For this purpose I am using surfaceview and embedding a map on it. On app initialisation, the surfaceview preview is enabled and the map is superimposed on the surface view. On clicking a button on the screen, a screenshot is taken using take screenshot function. The issue is that the screenshot does not capture the surfaceview preview and only the map superimposed on the surface view is visible in the screenshot (the rest of the surface view appears black in the screenshot).

Please advise how I can get the photo with the image of the map superimposed on it (as per the preview seen in surface view). Blocks used are attached.

Try this

1 Like

Hi :+1:
Do you have a picture of what you want to do? ,:+1:

Image overlaying image…

Thanks for your reply.

Attached is a picture of the actual app output. The black section behind the map should have been the screenshot of the preview being shown on the surface view. However I get a black screen with a map on it.

I want the preview of the surface view with the map super imposed on it

Please let me know your suggestions

1 Like

I’m trying to understand so I can suggest something But what is the objective? How and when should this happen? The user who will create the background? Should the background be the screenshot? Did you put an image and on that image you took a screenshot?

Thanks for your reply. I tried using the ComponentToImage extension. However despite storage, camera and location permissions being given to the app, the output file of component to image is not getting saved anywhere (default folder I read is /storage/emulated/0/.

Blocks are attached for your reference. Please let me know your suggestions on how I can get this to work.

Phone being used is a samsung J7 pro with android 9.

The objective is for the user of the app to be able to click a photo with a map (with their current location) superimposed on the photo. In the camera preview the map (with current location of the user) should also be superimposed on the photo (just as how the final photo will appear once the user clicks the button to take the photo).

storage/emulated/0/Android/data//files/

Your PackageName …:point_down:

I used Extension Component to Image :point_up:

Sorry, but I still don’t understand, but one of your problems is the path where the photo is being kept and maybe this will help you.
:point_down:

I’m trying to help… see, my goal:
1 - take a picture
2 - draw over the photo
3 - save the photo

1 Like

Thanks for the information on storage. I was able to find the image files based on the path given in the documentation you shared.

However the other issue still remains unresolved.

I am trying to create a camera app which superimposes a map with the current location of the user on the camera preview as well as the camera photo.

Both screenshot extension as well as ComponentToImage extension (component to image extension is used on surface view) are not able to capture the image/preview which is being shown by the camera. The are only picking up the map (on a black background).

Any suggestions you have to resolve the above issue would be much appreciated.

Thanks for the goal you have mentioned → 1) Take Photo 2) Draw over photo 3) Save photo.

I would like to modify it slightly 1) Show camera preview with map superimposed on it. Map should show the current location of the user 2) Take Photo 3) Do some processes to ensure that the map is super imposed on the photo as it appeared in the camera preview.

Can you suggest how the above can be accomplished?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.