From 0272fa5ccdaed1c3f329efad0b14e83fc0bc8aa4 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Tue, 28 Nov 2023 21:35:00 +0100 Subject: [PATCH] Change scanline order names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The scanline order ”bottom-top” has been changed to ”bottom_top”. The scanline order “top-bottom” has been changed to “top_bottom”. The scanline order names were changed so that API consumers can check if “tga_encoder.features.scanline_order.top_bottom” is truthy instead of having to check “tga_encoder.features.scanline_order["top-bottom"]”. This is a breaking change, but since no release of tga_encoder happened since commit 01bcbbf9272b39cd998f0daefc3b915ffa7d8300 which allowed the scanline order to be specified, it can not affect any mod on ContentDB. --- init.lua | 14 +++++++------- tools/generate_test_textures.lua | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/init.lua b/init.lua index 683a4a1..87c47fd 100644 --- a/init.lua +++ b/init.lua @@ -14,8 +14,8 @@ tga_encoder.features.compression = { ["RLE"] = true, } tga_encoder.features.scanline_order = { - ["bottom-top"] = true, - ["top-bottom"] = true, + ["bottom_top"] = true, + ["top_bottom"] = true, } local image = setmetatable({}, { @@ -76,8 +76,8 @@ function image:encode_image_spec(properties) ) local scanline_order = properties.scanline_order assert ( - "bottom-top" == scanline_order or - "top-bottom" == scanline_order + "bottom_top" == scanline_order or + "top_bottom" == scanline_order ) local pixel_depth if 0 ~= #properties.colormap then @@ -91,12 +91,12 @@ function image:encode_image_spec(properties) local x_origin_hi = 0 local y_origin_lo = 0 local y_origin_hi = 0 - local image_descriptor = 0 -- equal to bottom-top scanline order + local image_descriptor = 0 -- equal to bottom_top scanline order local width_lo = self.width % 256 local width_hi = math.floor(self.width / 256) local height_lo = self.height % 256 local height_hi = math.floor(self.height / 256) - if "top-bottom" == scanline_order then + if "top_bottom" == scanline_order then image_descriptor = 32 y_origin_lo = height_lo y_origin_hi = height_hi @@ -650,7 +650,7 @@ function image:encode(properties) local properties = properties or {} properties.colormap = properties.colormap or {} properties.compression = properties.compression or "RAW" - properties.scanline_order = properties.scanline_order or "bottom-top" + properties.scanline_order = properties.scanline_order or "bottom_top" self.pixel_depth = #self.pixels[1][1] * 8 diff --git a/tools/generate_test_textures.lua b/tools/generate_test_textures.lua index a6c9fee..7bc9d86 100755 --- a/tools/generate_test_textures.lua +++ b/tools/generate_test_textures.lua @@ -29,8 +29,8 @@ local pixels_colormapped_tb = { } local pixels_colormapped_by_scanline_order = { - ["bottom-top"] = pixels_colormapped_bt, - ["top-bottom"] = pixels_colormapped_tb, + ["bottom_top"] = pixels_colormapped_bt, + ["top_bottom"] = pixels_colormapped_tb, } local colormap_32bpp = { @@ -119,8 +119,8 @@ local pixels_rgba_tb = { } local pixels_rgba_by_scanline_order = { - ["bottom-top"] = pixels_rgba_bt, - ["top-bottom"] = pixels_rgba_tb, + ["bottom_top"] = pixels_rgba_bt, + ["top_bottom"] = pixels_rgba_tb, } local _ = { 0, 0, 0 } @@ -151,8 +151,8 @@ local pixels_rgb_tb = { } local pixels_rgb_by_scanline_order = { - ["bottom-top"] = pixels_rgb_bt, - ["top-bottom"] = pixels_rgb_tb, + ["bottom_top"] = pixels_rgb_bt, + ["top_bottom"] = pixels_rgb_tb, } local tga_type_by_compression = {