Generate TGA type 3 test textures using loops

This commit is contained in:
Nils Dagsson Moskopp 2023-10-17 20:12:23 +02:00
parent 6db7be7b9d
commit fa28f4c8de
Signed by: erlehmann
GPG Key ID: A3BC671C35191080
1 changed files with 63 additions and 21 deletions

View File

@ -28,11 +28,43 @@ local pixels_colormapped_tb = {
{ _, _, _, _, _, B, _, B, },
}
local pixels_by_scanline_order = {
local pixels_colormapped_by_scanline_order = {
["bottom-top"] = pixels_colormapped_bt,
["top-bottom"] = pixels_colormapped_tb,
}
local _ = { 0 }
local R = { 127 }
local G = { 255 }
local B = { 191 }
local pixels_grayscale_bt = {
{ _, _, _, _, _, B, _, B, },
{ _, _, _, _, _, B, B, B, },
{ _, _, G, G, G, B, _, B, },
{ _, _, G, _, G, B, B, B, },
{ _, R, G, _, _, _, _, _, },
{ _, R, G, G, G, _, _, _, },
{ _, R, _, _, _, _, _, _, },
{ R, R, R, _, _, _, _, _, },
}
local pixels_grayscale_tb = {
{ R, R, R, _, _, _, _, _, },
{ _, R, _, _, _, _, _, _, },
{ _, R, G, G, G, _, _, _, },
{ _, R, G, _, _, _, _, _, },
{ _, _, G, _, G, B, B, B, },
{ _, _, G, G, G, B, _, B, },
{ _, _, _, _, _, B, B, B, },
{ _, _, _, _, _, B, _, B, },
}
local pixels_grayscale_by_scanline_order = {
["bottom-top"] = pixels_grayscale_bt,
["top-bottom"] = pixels_grayscale_tb,
}
local colormap_32bpp = {
{ 0, 0, 0, 128 },
{ 255, 0, 0, 255 },
@ -63,29 +95,39 @@ local colormap_by_color_format = {
for _, color_format in ipairs(
tga_encoder.features.color_format
) do
-- a grayscale colormap makes little sense
if ("Y8" ~= color_format) then
for _, scanline_order in ipairs(
tga_encoder.features.scanline_order
) do
local filename = "type1" ..
for _, scanline_order in ipairs(
tga_encoder.features.scanline_order
) do
local filename
local pixels
if ("Y8" == color_format) then
filename = "type3" ..
'_' .. color_format ..
'_' .. scanline_order ..
'.tga'
print(filename)
local colormap = colormap_by_color_format[
color_format
'_' .. scanline_order ..
'.tga'
pixels = pixels_grayscale_by_scanline_order[
scanline_order
]
else
filename = "type1" ..
'_' .. color_format ..
'_' .. scanline_order ..
'.tga'
pixels = pixels_colormapped_by_scanline_order[
scanline_order
]
local properties = {
colormap = colormap,
color_format = color_format,
scanline_order = scanline_order,
}
local image = tga_encoder.image(
pixels_by_scanline_order[scanline_order]
)
image:save(filename, properties)
end
local colormap = colormap_by_color_format[
color_format
]
local properties = {
colormap = colormap,
color_format = color_format,
scanline_order = scanline_order,
}
print(filename)
local image = tga_encoder.image(pixels)
image:save(filename, properties)
end
end