Post subject: [Lua] How do I use gui.drawimage() ?
Lil_Gecko
He/Him
Player (98)
Joined: 4/7/2011
Posts: 520
This might look like a stupid question but I can't figure it out for the life of me. Whatever the argument I passed I always get a "Bad Image Data" error. The only thing working is if I previously do img = gui.gdscreenshot(); then gui.drawimage(img) works. But I want to use one of my own image not a screenshot. Thanks :)
Editor, Skilled player (1338)
Joined: 1/31/2010
Posts: 330
Location: France
Here is the documentation about this function I found for the FCEUX emulator (I assume it must work the same way with PSXjin)
gui.gdoverlay([int dx=0, int dy=0,] string str [, sx=0, sy=0, sw, sh] [, float alphamul=1.0]) gui.image([int dx=0, int dy=0,] string str [, sx=0, sy=0, sw, sh] [, float alphamul=1.0]) gui.drawimage([int dx=0, int dy=0,] string str [, sx=0, sy=0, sw, sh] [, float alphamul=1.0]) Draws an image on the screen. gdimage must be in truecolor gd string format. Transparency is fully supported. Also, if alphamul is specified then it will modulate the transparency of the image even if it's originally fully opaque. (alphamul=1.0 is normal, alphamul=0.5 is doubly transparent, alphamul=3.0 is triply opaque, etc.) dx,dy determines the top-left corner of where the image should draw. If they are omitted, the image will draw starting at the top-left corner of the screen. gui.gdoverlay is an actual drawing function (like gui.box and friends) and thus must be called every frame, preferably inside a gui.register'd function, if you want it to appear as a persistent image onscreen. Here is an example that loads a PNG from file, converts it to gd string format, and draws it once on the screen: local gdstr = gd.createFromPng("myimage.png"):gdStr() gui.gdoverlay(gdstr)
Lil_Gecko
He/Him
Player (98)
Joined: 4/7/2011
Posts: 520
Thanks !
require "gd"

local gdstr = gd.createFromPng("a.png"):gdStr()

while true do
gui.gdoverlay(gdstr)
emu.frameadvance()
end
works perfectly as long as the dll are there.