#!/usr/bin/env lua5.1 dofile("../init.lua") local _ = { 0 } local R = { 1 } local G = { 2 } local B = { 3 } local pixels_colormapped_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_colormapped_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_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 }, { 0, 255, 0, 255 }, { 0, 0, 255, 255 }, } local colormap_24bpp = { { 0, 0, 0 }, { 255, 0, 0 }, { 0, 255, 0 }, { 0, 0, 255 }, } local colormap_16bpp = { { 0, 0, 0, 0 }, { 255, 0, 0, 255 }, { 0, 255, 0, 255 }, { 0, 0, 255, 255 }, } local colormap_by_color_format = { ["A1R5G5B5"] = colormap_16bpp, ["B8G8R8"] = colormap_24bpp, ["B8G8R8A8"] = colormap_32bpp, } for _, color_format in ipairs( tga_encoder.features.color_format ) do 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' pixels = pixels_grayscale_by_scanline_order[ scanline_order ] else filename = "type1" .. '_' .. color_format .. '_' .. scanline_order .. '.tga' pixels = pixels_colormapped_by_scanline_order[ scanline_order ] 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 local _ = { 0, 0, 0, 128 } local R = { 255, 0, 0, 255 } local G = { 0, 255, 0, 255 } local B = { 0, 0, 255, 255 } local pixels_rgba_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_rgba_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, }, } image_rgba_bt = tga_encoder.image(pixels_rgba_bt) image_rgba_tb = tga_encoder.image(pixels_rgba_tb) image_rgba_bt:save( "type2_32bpp_bt.tga", { color_format="B8G8R8A8", compression="RAW", scanline_order = "bottom-top" } ) image_rgba_tb:save( "type2_32bpp_tb.tga", { color_format="B8G8R8A8", compression="RAW", scanline_order = "top-bottom" } ) image_rgba_bt:save( "type10_32bpp_bt.tga", { color_format="B8G8R8A8", compression="RLE", scanline_order = "bottom-top" } ) image_rgba_tb:save( "type10_32bpp_tb.tga", { color_format="B8G8R8A8", compression="RLE", scanline_order = "top-bottom" } ) local _ = { 0, 0, 0 } local R = { 255, 0, 0 } local G = { 0, 255, 0 } local B = { 0, 0, 255 } local pixels_rgb_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_rgb_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, }, } image_rgb_bt = tga_encoder.image(pixels_rgb_bt) image_rgb_tb = tga_encoder.image(pixels_rgb_tb) image_rgb_bt:save( "type2_24bpp_bt.tga", { color_format="B8G8R8", compression="RAW", scanline_order = "bottom-top" } ) image_rgb_tb:save( "type2_24bpp_tb.tga", { color_format="B8G8R8", compression="RAW", scanline_order = "top-bottom" } ) image_rgb_bt:save( "type10_24bpp_bt.tga", { color_format="B8G8R8", compression="RLE", scanline_order = "bottom-top" } ) image_rgb_tb:save( "type10_24bpp_tb.tga", { color_format="B8G8R8", compression="RLE", scanline_order = "top-bottom" } ) image_rgb_bt:save( "type2_16bpp_bt.tga", { color_format="A1R5G5B5", compression="RAW", scanline_order = "bottom-top" } ) image_rgb_tb:save( "type2_16bpp_tb.tga", { color_format="A1R5G5B5", compression="RAW", scanline_order = "top-bottom" } ) image_rgb_bt:save( "type10_16bpp_bt.tga", { color_format="A1R5G5B5", compression="RLE", scanline_order = "bottom-top" } ) image_rgb_tb:save( "type10_16bpp_tb.tga", { color_format="A1R5G5B5", compression="RLE", scanline_order = "top-bottom" } )