X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=blender%2Fio_mspgl%2Fexport_texture.py;h=dd8191ce9f108652b2924ee1a77fbd0197d0f94c;hb=HEAD;hp=3194edae8e53e1a407acac8073327ba818e52bdd;hpb=d9fbb830ddf5c9b69a046a641b16d6ae25d216b1;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_texture.py b/blender/io_mspgl/export_texture.py index 3194edae..2269e27a 100644 --- a/blender/io_mspgl/export_texture.py +++ b/blender/io_mspgl/export_texture.py @@ -23,55 +23,73 @@ def pixels_to_gray(pixels): for i in range(0, len(pixels), 4): yield int((pixels[i]+pixels[i+1]+pixels[i+2])*255/3) +def pixels_to_single_channel(pixels, channel): + for i in range(0, len(pixels), 4): + yield int(pixels[i+channel]*255) + class TextureExporter: def export_texture(self, tex_node, channels=['R', 'G', 'B']): image = tex_node.image from .datafile import RawData, Resource, Statement, Token - tex_res = Resource(image.name+".tex", "texture") + tex_res = Resource(self.get_texture_name(tex_node, channels), "texture") tex_res.statements.append(Statement("type", Token("\\2d"))) if tex_node.use_mipmap: tex_res.statements.append(Statement("generate_mipmap", True)) - colorspace = image.colorspace_settings.name - if len(channels)==1 and colorspace=='sRGB': - raise Exception("Unsupported configuration on texture {}: Grayscale with sRGB".format(image.name)) + from .texture import Texture + texture = Texture(tex_node, channels) invert_mask = sum(1<