X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=scripts%2Fmaketex.py;h=82a331a9cbbe3af5af0eeb4208b95b8ab09de767;hb=55dbeb5e04516699b8415104e346243d5e4c48c9;hp=04de1d38a57d51cc2e25c2ea16f8e5896481283a;hpb=869a1d1bcdeea9908664d3901b5b6b34634d833b;p=libs%2Fgl.git diff --git a/scripts/maketex.py b/scripts/maketex.py index 04de1d38..82a331a9 100755 --- a/scripts/maketex.py +++ b/scripts/maketex.py @@ -13,8 +13,8 @@ def escape(str): result += c return result; -def make_tex(fn, filter="LINEAR", anisotropy=0, wrap=None): - import Image +def make_tex(fn, filter="LINEAR", anisotropy=0, wrap=None, srgb=False): + from PIL import Image img = Image.open(fn) @@ -24,6 +24,9 @@ def make_tex(fn, filter="LINEAR", anisotropy=0, wrap=None): elif fmt=="L": fmt = "LUMINANCE" + if srgb: + fmt = "S"+fmt + result = "storage %s %d %d;\n"%(fmt, img.size[0], img.size[1]) result += "filter %s;\n"%filter if "MIPMAP" in filter: @@ -50,6 +53,7 @@ if __name__=="__main__": parser.add_argument("-f", "--filter", choices=["NEAREST", "LINEAR", "MIPMAP"], default="LINEAR", help="Filtering mode") parser.add_argument("-a", "--anisotropy", metavar="NUMBER", help="Maximum anisotropy, 0 = disable") parser.add_argument("-w", "--wrap", choices=["REPEAT", "CLAMP_TO_EDGE", "MIRRORED_REPEAT"], help="Wrapping mode") + parser.add_argument("--srgb", action="store_const", const=True, help="Use sRGB color space") parser.add_argument("image") args = parser.parse_args() @@ -62,4 +66,4 @@ if __name__=="__main__": if not out_fn: out_fn = os.path.splitext(args.image)[0]+".tex2d" out = file(out_fn, "w") - out.write(make_tex(args.image, filter, args.anisotropy, args.wrap)) + out.write(make_tex(args.image, filter, args.anisotropy, args.wrap, args.srgb))