How do I update the image editor with rendered image?

Hi all, I’m working on putting pieces of scripts together to get a more integrated Appleseed exporter/rendering interface (just for fun? Just for my own personal use? I dunno).

Rendering can be done either via command line or via the appleseed.studio GUI. Either way, I’d like to be able to update the image editor with the rendered image after rendering finishes. Hey, even WHILE it’s rendering, that would be great.

Can someone tell me how that’s done? Is there a particular function in bpy.types.RenderEngine that can be called to assist with that?

See the check for ‘preview’ in the example code, maybe that helps

http://www.blender.org/documentation/blender_python_api_2_67_1/bpy.types.RenderEngine.html

Here is a code section from the 3Delight exporter.


        def update_image():
            result = engine.begin_result(0, 0, engine.rpass.resolution[0], engine.rpass.resolution[1])
            lay = result.layers[0]
            # possible the image wont load early on.
            try:
                lay.load_from_file(render_output)
            except:
                pass
            engine.end_result(result)

layers has a load_from_file method otherwise you will have to construct an array of pixels.

How does one ‘construct an array of pixels’ here? I’m slowly getting these examples, but it’s still really vague to me…

The custom render engine example code shows how to construct a pixel array. Inside def render_scene.

Mmkay, thank you. The words in that section are kind of ambiguous to me for some reason, I guess I just need to test it out and see what it does in order to make it “real” to me.