diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index 3d3130d1..2bb89116 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -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; diff --git a/web/help/LuaFunctionsList.html b/web/help/LuaFunctionsList.html index 6f05f375..0669b5cc 100644 --- a/web/help/LuaFunctionsList.html +++ b/web/help/LuaFunctionsList.html @@ -624,12 +624,14 @@

gui.savescreenshotas(string name)

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.

-

string gui.gdscreenshot()

+

string gui.gdscreenshot(bool getemuscreen)


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.


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.


+

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.

+


Warning: 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.


gui.gdoverlay([int dx=0, int dy=0,] string str [, sx=0, sy=0, sw, sh] [, float alphamul=1.0])