By way of intro, I have posted this
http://lemmasoft.renai.us/forums/viewto ... it=surface
in a separate subforum just to self-track my progress on Ren'Py 6.99 and the need to use Creator Defined Displayables (CDD)
now that renpygame has been made incompatible/obsolete with implementation of pygame_SDL2.
I accept the need to use CDD and break away from renpygame,
and have successfully used a cutdown version of Appearing class from the doco
http://www.renpy.org/doc/html/udd.html
with the logo.png file as a test case to save a Surface as a PNG file
using a combination of:
- defining an image in Ren'Py ,
- instantiating my custom CDD with that image as a parameter,
- calling renpy.load_surface within a CDD custom method with self.child parameter,
- and the pygame_SDL2.image.save method with that Surface and a path/filename as parameters to output a PNG file.
That's great for "logo.png".
However, I cannot get my own generated image to save as PNG.
The image I need to save is a LiveComposite of eight paperdoll layered images,
which I am guessing I need to flatten to a single texture before my CDD will accept it as an 'image' per se.
So I have done that using the renpy Flatten method, using the output image as a parameter for the CDD.
However that image is not being accepted as an image, it is being rejected either as:
NameError: global name 'charflat' is not defined
or
Exception: Expected an image, but got a general displayable.
I will update this with full tracebacks and animegen.rpy code attachment for clarity.
So firstly, I have my LiveComposite image which my custom screen language definition successfully uses (see code attachment for draw_char definition & screen),
and another image declaration to Flatten that LiveComposite.
image char = DynamicDisplayable(draw_char)
image charflat=Flatten("char")
In testing, I tried three ways to instantiate the CDD class which I have named PNG
before calling the CDD method to save the image as a PNG via python statement: myPNG.imagesave(pngpath)
1. myPNG=PNG("logo.png")
This works perfectly, outputting a file named test.png to my saves subdirectory, which matches logo.png
- so the image is presumably being loaded from disk to image cache and from there into the CDD self.child, to a load_surface, and to the image.save.
2. myPNG=PNG("charflat")
This gets me the "Exception: Expected an image, but got a general displayable."
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/animegen.rpy", line 372, in script
$myPNG.imagesave(pngpath)
File "game/animegen.rpy", line 372, in <module>
$myPNG.imagesave(pngpath)
File "game/animegen.rpy", line 27, in imagesave
surf=renpy.load_surface(self.child)
Exception: Expected an image, but got a general displayable.
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/animegen.rpy", line 372, in script
$myPNG.imagesave(pngpath)
File "E:\dev\renpy\renpy-6.99.3-sdk\renpy\ast.py", line 785, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "E:\dev\renpy\renpy-6.99.3-sdk\renpy\python.py", line 1445, in py_exec_bytecode
exec bytecode in globals, locals
File "game/animegen.rpy", line 372, in <module>
$myPNG.imagesave(pngpath)
File "game/animegen.rpy", line 27, in imagesave
surf=renpy.load_surface(self.child)
File "E:\dev\renpy\renpy-6.99.3-sdk\renpy\display\im.py", line 1601, in load_surface
return cache.get(image(im))
File "E:\dev\renpy\renpy-6.99.3-sdk\renpy\display\im.py", line 1564, in image
return image(arg.target, loose=loose, **properties)
File "E:\dev\renpy\renpy-6.99.3-sdk\renpy\display\im.py", line 1579, in image
raise Exception("Expected an image, but got a general displayable.")
Exception: Expected an image, but got a general displayable.
Windows-7-6.1.7601-SP1
Ren'Py 6.99.3.404
AnimeGen 0.0
This gets me the "NameError: global name 'charflat' is not defined":
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/animegen.rpy", line 370, in script
$myPNG=PNG(charflat)
File "game/animegen.rpy", line 370, in <module>
$myPNG=PNG(charflat)
NameError: name 'charflat' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/animegen.rpy", line 370, in script
$myPNG=PNG(charflat)
File "E:\dev\renpy\renpy-6.99.3-sdk\renpy\ast.py", line 785, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "E:\dev\renpy\renpy-6.99.3-sdk\renpy\python.py", line 1445, in py_exec_bytecode
exec bytecode in globals, locals
File "game/animegen.rpy", line 370, in <module>
$myPNG=PNG(charflat)
NameError: name 'charflat' is not defined
Windows-7-6.1.7601-SP1
Ren'Py 6.99.3.404
AnimeGen 0.0
Thanks again for reading, I really appreciate your time!