Add getemuscreen support to gui.gdscreenshot Lua call

This commit is contained in:
Brendan Byrd 2018-11-16 02:55:08 +00:00
parent 5f23a565e8
commit 76c423fa4a
2 changed files with 8 additions and 3 deletions

View File

@ -3737,7 +3737,7 @@ static int gui_savescreenshot(lua_State *L) {
return 1;
}
// gui.gdscreenshot()
// gui.gdscreenshot(getemuscreen)
//
// Returns a screen shot as a string in gd's v1 file format.
// This allows us to make screen shots available without gd installed locally.
@ -3748,6 +3748,7 @@ static int gui_savescreenshot(lua_State *L) {
// It really is easier that way.
// example: gd.createFromGdStr(gui.gdscreenshot()):png("outputimage.png")
static int gui_gdscreenshot(lua_State *L) {
bool getemuscreen = (lua_toboolean(L,1) == 1);
int width = LUA_SCREEN_WIDTH;
int height = LUA_SCREEN_HEIGHT;
@ -3770,9 +3771,11 @@ static int gui_gdscreenshot(lua_State *L) {
*ptr++ = 255;
*ptr++ = 255;
uint8* scrBuf = getemuscreen ? XBackBuf : XBuf;
for (int y=0; y < height; y++) {
for (int x=0; x < width; x++) {
uint8 index = XBuf[(y)*256 + x];
uint8 index = scrBuf[(y)*256 + x];
// Write A,R,G,B (alpha=0 for us):
*ptr = 0;

View File

@ -624,12 +624,14 @@
<p><span class="rvts63">gui.savescreenshotas(string name)</span></p>
<p><span class="rvts37">Makes a screenshot of the FCEUX emulated screen, and saves it to the appropriate folder. However, this one receives a file name for the screenshot.</span></p>
<p><span class="rvts37"> </span></p>
<p><span class="rvts63">string gui.gdscreenshot()</span></p>
<p><span class="rvts63">string gui.gdscreenshot(bool getemuscreen)</span></p>
<p><span class="rvts37"><br/></span></p>
<p><span class="rvts37">Takes a screen shot of the image and returns it in the form of a string which can be imported by the gd library using the gd.createFromGdStr() function.</span></p>
<p><span class="rvts37"><br/></span></p>
<p><span class="rvts37">This function is provided so as to allow FCEUX to not carry a copy of the gd library itself. If you want raw RGB32 access, skip the first 11 bytes (header) and then read pixels as Alpha (always 0), Red, Green, Blue, left to right then top to bottom, range is 0-255 for all colors.</span></p>
<p><span class="rvts37"><br/></span></p>
<p><span class="rvts37">If getemuscreen is false, this gets background colors from either the screen pixel or the LUA pixels set, but LUA data may not match the information used to put the data to the screen. If getemuscreen is true, this gets background colors from anything behind an LUA screen element.</span></p>
<p><span class="rvts37"><br/></span></p>
<p><span class="rvts68">Warning:</span><span class="rvts37"> Storing screen shots in memory is not recommended. Memory usage will blow up pretty quick. One screen shot string eats around 230 KB of RAM.</span></p>
<p><span class="rvts37"><br/></span></p>
<p><span class="rvts63">gui.gdoverlay([int dx=0, int dy=0,] string str [, sx=0, sy=0, sw, sh] [, float alphamul=1.0])</span></p>