Custom image file format plugin - possible?

Is it possible to create an image import script for loading an image file format? Want to use this file format for materials. Where do I start? Google hasn’t been particularly helpful on finding information on it. Thanks.

It is possible, you need to decode the data to raw RGBA floats and assign a flat sequence to Image.pixels (must match dimensions).

It’s potentially slow using python, you may want to get numpy and use it for computation if there’s a performance problem for you.

import bpy

width = 300
height = 300

img = bpy.data.images.new("PyImage", width, height)

data = [b for a in
           [(1-i/(width-1), 1-j/(height-1), 0, 1) for i in range(width) for j in range(height)]
        for b in a]
        
img.pixels[:] = data

You can read binary data using struct.unpack:

http://docs.python.org/3.3/library/struct.html