Ver código fonte

new oxyresbuild options

dmuratshin 9 anos atrás
pai
commit
16048c2a98
2 arquivos alterados com 9 adições e 3 exclusões
  1. 4 0
      tools/oxyresbuild.py
  2. 5 3
      tools/resbuild/process_atlas.py

+ 4 - 0
tools/oxyresbuild.py

@@ -38,6 +38,8 @@ def get_parser():
         "Value > 1 - upscale, Value < 1 - downscale. Should be used "
         "Value > 1 - upscale, Value < 1 - downscale. Should be used "
         "with --resize", type=float, default=1.0
         "with --resize", type=float, default=1.0
     )
     )
+    parser.add_argument(
+        "--trim_threshold", help="Alpha trim threshold. Used to optimize image when trimming transparent borders of image", type=int, default=2)
     parser.add_argument("-r", "--resize", help="Resize images by a scale value",
     parser.add_argument("-r", "--resize", help="Resize images by a scale value",
                         action="store_true", default=False)
                         action="store_true", default=False)
     parser.add_argument("-us", "--upscale",
     parser.add_argument("-us", "--upscale",
@@ -57,6 +59,8 @@ def get_parser():
                         action="store_true", default=False)
                         action="store_true", default=False)
     parser.add_argument("-w", "--warnings", help="show warnings",
     parser.add_argument("-w", "--warnings", help="show warnings",
                         action="store_true", default=False)
                         action="store_true", default=False)
+    parser.add_argument("--simple_downsample", help="don't use smart algorithm when resizing args",
+                        action="store_true", default=False)
     parser.add_argument(
     parser.add_argument(
         "-v", "--verbosity", help="verbosity level. 1 - only errors, "
         "-v", "--verbosity", help="verbosity level. 1 - only errors, "
         "2 - normal. Default value is 2", type=int, default=2)
         "2 - normal. Default value is 2", type=int, default=2)

+ 5 - 3
tools/resbuild/process_atlas.py

@@ -47,7 +47,7 @@ def as_bool(attr, df=False):
     return lw == "true" or lw == "1"
     return lw == "true" or lw == "1"
 
 
 
 
-def fixImage(image):
+def fixImage_unused(image):
     if image.mode != "RGBA":
     if image.mode != "RGBA":
         return image
         return image
 
 
@@ -450,7 +450,7 @@ def processRS(context, walker):
                 resize_filter = Image.BICUBIC
                 resize_filter = Image.BICUBIC
 
 
             if context.args.resize:
             if context.args.resize:
-                if as_bool(image_el.getAttribute("trueds")) or (not trim and not extend):
+                if as_bool(image_el.getAttribute("trueds")) or (not trim and not extend) or context.args.simple_downsample:
                     frame_image = frame_image.resize(
                     frame_image = frame_image.resize(
                         (frame_size[0], frame_size[1]), resize_filter)
                         (frame_size[0], frame_size[1]), resize_filter)
                 else:
                 else:
@@ -470,7 +470,9 @@ def processRS(context, walker):
 
 
             if image.mode == "RGBA" and trim:
             if image.mode == "RGBA" and trim:
                 r, g, b, a = frame_image.split()
                 r, g, b, a = frame_image.split()
-                a = a.point(lambda p: p - 2)
+                tt = context.args.trim_threshold
+                if tt:
+                	a = a.point(lambda p: p - tt)
 
 
                 if walker.hit_test:
                 if walker.hit_test:
                     adata = makeAlpha(a)
                     adata = makeAlpha(a)