mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 03:39:51 +00:00
Test new function to save images with a specific palette
This commit is contained in:
parent
b43e21baba
commit
adc97fffb7
@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2018-2019 Igara Studio S.A.
|
Copyright (c) 2018-2020 Igara Studio S.A.
|
||||||
Copyright (c) 2018 David Capello
|
Copyright (c) 2018 David Capello
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
-- Copyright (C) 2019 Igara Studio S.A.
|
-- Copyright (C) 2019-2020 Igara Studio S.A.
|
||||||
-- Copyright (C) 2018 David Capello
|
-- Copyright (C) 2018 David Capello
|
||||||
--
|
--
|
||||||
-- This file is released under the terms of the MIT license.
|
-- This file is released under the terms of the MIT license.
|
||||||
@ -95,6 +95,47 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Save indexed image and load and check that the palette is the same
|
||||||
|
do
|
||||||
|
local spr = Sprite{ fromFile="sprites/abcd.aseprite" }
|
||||||
|
local img = Image{ fromFile="sprites/abcd.aseprite" }
|
||||||
|
spr.cels[1].image:saveAs("_test_palette_a.png")
|
||||||
|
img:saveAs("_test_palette_b.png") -- This file will contain a black palette
|
||||||
|
img:saveAs{ filename="_test_palette_c.png", palette=spr.palettes[1] }
|
||||||
|
|
||||||
|
local a = Sprite{ fromFile="_test_palette_a.png" }
|
||||||
|
local b = Sprite{ fromFile="_test_palette_b.png" }
|
||||||
|
local c = Sprite{ fromFile="_test_palette_c.png" }
|
||||||
|
|
||||||
|
assert(a.width == 5)
|
||||||
|
assert(a.height == 7)
|
||||||
|
assert(b.width == 32)
|
||||||
|
assert(b.height == 32)
|
||||||
|
assert(c.width == 32)
|
||||||
|
assert(c.height == 32)
|
||||||
|
local bimg = b.cels[1].image
|
||||||
|
local cimg = c.cels[1].image
|
||||||
|
for y=0,31 do
|
||||||
|
for x=0,31 do
|
||||||
|
assert(bimg:getPixel(x, y) == cimg:getPixel(x, y))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local apal = a.palettes[1]
|
||||||
|
local bpal = b.palettes[1]
|
||||||
|
local cpal = c.palettes[1]
|
||||||
|
-- Same palette in a and c
|
||||||
|
assert(#apal == #cpal)
|
||||||
|
for i=0,#apal-1 do
|
||||||
|
assert(apal:getColor(i) == cpal:getColor(i))
|
||||||
|
end
|
||||||
|
-- b should contain a complete black palette
|
||||||
|
assert(bpal:getColor(0) == Color(0, 0, 0, 0))
|
||||||
|
for i=1,#bpal-1 do
|
||||||
|
assert(bpal:getColor(i) == Color(0, 0, 0, 255))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Resize image
|
-- Resize image
|
||||||
do
|
do
|
||||||
local a = Sprite(3, 2)
|
local a = Sprite(3, 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user