How to export .tex file to .png file?


Recommended Posts

Is there a way of exporting .tex file to .png file? .tex file in Griftlands doesn't work with any general purpose image editing tool like photoshop, so I want to export it to .png. I saw there's an in-game function for exporting textures(engine.inst:SaveTextureToPNG), but I didn't get it to work. Maybe because I put the wrong parameters? Moreover, this function works for exporting card images, but does not work for exporting portraits(if it worked, I have no idea where the exported portrait went). There is no way for me to debug this function's behavior, and there is no indication whether this function succeeded or not other than the fact that lua didn't crash, so I really don't know what this function does.

Link to comment
Share on other sites

  • Developer
On 5/23/2020 at 7:30 PM, RageLeague said:

I saw there's an in-game function for exporting textures(engine.inst:SaveTextureToPNG), but I didn't get it to work. Maybe because I put the wrong parameters? Moreover, this function works for exporting card images, but does not work for exporting portraits(if it worked, I have no idea where the exported portrait went).

If you run the MainMenu:ExportPortraits() function, it goes through all the named agents in the game, instantiates their anim, positions them correctly, crops them and exports a PNG of their portrait to contentsrc\images\portraits (in the game's installation folder). That's how we generate updated portrait textures for each character. You can tweak that to be able to export other widgets.

Link to comment
Share on other sites

13 hours ago, ricardopinto said:

If you run the MainMenu:ExportPortraits() function, it goes through all the named agents in the game, instantiates their anim, positions them correctly, crops them and exports a PNG of their portrait to contentsrc\images\portraits (in the game's installation folder). That's how we generate updated portrait textures for each character. You can tweak that to be able to export other widgets.

I assume that the button under tools does the same thing?

My problem is that nothing is generated under my game installation folder, at least in the experimental version, even though I pressed "export portrait"

 

Link to comment
Share on other sites

  • Developer

I looked into it, and there are a couple of things stopping the engine savetopng from working the way you're expecting. I'll wrap it in something that will make it useable and push it out in experimental tonight. 

(edit)

If you're keen, this is the code:

function UIHelpers.SaveTextureAsPNG(texture, filename)
    local w, h = texture:GetSize()
    local scene = engine.rendering.Scene()
    local capture = Widget.CaptureImage(scene):SetSize( w, h )
    local container = Widget()
    local anim = container:AddChild(Widget.Image(texture):SetSize(w,h))
    local root = engine.rendering.SceneGraphNode()
    root:SetScene(scene)
    root:AddChild(container.node)
    capture:RenderToScene( container, -w/2, -h/2, w/2, h/2 )
    engine.inst:SaveTextureToPNG( capture:GetTexture(), "SETTINGS:"..filename .. ".png" );
end
 

It saves stuff one directory up from where your save files usually go.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.