Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] I'm trying to render a photo on screen and export it as a separate image file on mobile and need help [meme maker]

Author
Message
THE_NOTORIOUS_PIGGY
3
Years of Service
User Offline
Joined: 17th Jun 2016
Location:
Posted: 9th Sep 2018 21:23
Hello all,
I'm making a meme creator app, where you import an image and write text and export the image into your devices photo library.
Problem is, I cannot figure out how to grab a portion of the screen and export it.
How can I program my app to take a photo of the screen and export it?

The author of this post has marked a post as an answer.

Go to answer

blink0k
AGK Developer
Gold Codemaster
6
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Sep 2018 01:55
You need to use a couple of commands; createrenderimage() and setrendertoimage() then saveimage() to save it to a file
There is an example in the projects delivered with your product called "rendertoimage" have a look at that
THE_NOTORIOUS_PIGGY
3
Years of Service
User Offline
Joined: 17th Jun 2016
Location:
Posted: 10th Sep 2018 13:37
I'm really lost. So far from what I understand, createrenderimage() is basically the canvas, onto which everything is rendered and further saved?
In my set-up file I have
CreateRenderImage(100,screen_x,screen_y,1,0)
screen_x&y is the apps resolution btw

Then, I have a button that when pressed runs this function



I'd appreciate more help with this. Where can I even find the photo I have saved? I've looked in the apps folder. I'm not sure what I am doing wrong

Green7
13
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: Switzerland
Posted: 10th Sep 2018 15:29
Not sure if it's the ClearScreen() command that wipes the screen. If you wipe the screen and then try to grab an image, im pretty sure you will get nothing but an empty pic.
Bengismo
1
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
blink0k
AGK Developer
Gold Codemaster
6
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 11th Sep 2018 01:02
My apologies. Actually you can use the getimage() function to create an image from a region of the screen
THE_NOTORIOUS_PIGGY
3
Years of Service
User Offline
Joined: 17th Jun 2016
Location:
Posted: 11th Sep 2018 11:29
So I've been working on this, and I kinda got somewhere but I'm back into trouble.


Now this kinda works, it exports a photo when I test it on an android AppGameKit player, however the photo is just completely black and 1080x1920 resolution. How can I fix this?

if I replace printimage() with saveimage(), absolutely nothing happens. Has anyone used saveimage? I don't know where the image gets saved when I try using tutorial scripts.

I've tried
CreateRenderImage(1,screen_x,screen_y,1,0)
and into the loop putting
SetRenderToImage(1,0)
SetRenderToScreen()
but that just gives me a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT error message.
blink0k
AGK Developer
Gold Codemaster
6
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 11th Sep 2018 21:32 Edited at: 11th Sep 2018 21:32
Try this before you save the image
SetRawWritePath(GetReadPath())
The file will be in the media directory
THE_NOTORIOUS_PIGGY
3
Years of Service
User Offline
Joined: 17th Jun 2016
Location:
Posted: 12th Sep 2018 00:14 Edited at: 12th Sep 2018 00:18
Thank you @blink0k!
Okay, so with that I finally managed to get it to save an image on my computer. The problem is, it just saves a blank image
Now, my app looks like this:
First button prompts you to add an image, second button adds text and third button saves it


now when I hit save, I would like it to save the photo AND the text. Is this possible? if so, can someone guide me?
Also I have noticed, that when I save the image as a .jpg the background in the photo is white, but saved as a .png the photo is black
blink0k
AGK Developer
Gold Codemaster
6
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Sep 2018 01:24 Edited at: 12th Sep 2018 01:26
This post has been marked by the post author as the answer.
Try adding;
DrawSprite(spriteHandl)
DrawText(textHandle)

Before you getImage()

The .png has a black background because the background is transparent. Maybe use drawbox() to fill the background with a colour
THE_NOTORIOUS_PIGGY
3
Years of Service
User Offline
Joined: 17th Jun 2016
Location:
Posted: 12th Sep 2018 12:49
That's exactly what I was looking for. Thank you

Login to post a reply

Server time is: 2019-09-22 03:24:04
Your offset time is: 2019-09-22 03:24:04