Merge pull request #2671 from sarametz/png8_encoding_bug
Png8 encoding bug
This commit is contained in:
commit
c361e538f7
7 changed files with 58 additions and 2 deletions
|
@ -393,7 +393,7 @@ private:
|
|||
// clip extreme alfa values
|
||||
void create_palette_rek(std::vector<rgba> & palette, node * itr) const
|
||||
{
|
||||
if (itr->count >= 3)
|
||||
if (itr->count != 0)
|
||||
{
|
||||
unsigned count = itr->count;
|
||||
byte a = byte(itr->alphas/float(count));
|
||||
|
|
|
@ -541,7 +541,7 @@ void save_as_png8_oct(T1 & file,
|
|||
trees[j].create_palette(pal);
|
||||
leftovers = cols[j] - static_cast<unsigned>(pal.size());
|
||||
cols[j] = static_cast<unsigned>(pal.size());
|
||||
palette.insert(palette.begin(), pal.begin(), pal.end());
|
||||
palette.insert(palette.end(), pal.begin(), pal.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
BIN
tests/python_tests/images/support/encoding-opts/png8-17cols.png
Normal file
BIN
tests/python_tests/images/support/encoding-opts/png8-17cols.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 192 B |
BIN
tests/python_tests/images/support/encoding-opts/png8-2px.A.png
Normal file
BIN
tests/python_tests/images/support/encoding-opts/png8-2px.A.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 351 B |
BIN
tests/python_tests/images/support/encoding-opts/png8-2px.png
Normal file
BIN
tests/python_tests/images/support/encoding-opts/png8-2px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 351 B |
BIN
tests/python_tests/images/support/encoding-opts/png8-9cols.png
Normal file
BIN
tests/python_tests/images/support/encoding-opts/png8-9cols.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 171 B |
|
@ -157,6 +157,62 @@ if mapnik.has_png():
|
|||
eq_(len(im.tostring('png8:t=0')) == len(im_in.tostring('png8')), True)
|
||||
eq_(len(im.tostring('png8:t=0:m=o')) == len(im_in.tostring('png8:m=o')), True)
|
||||
|
||||
def test_9_colors_hextree():
|
||||
expected = './images/support/encoding-opts/png8-9cols.png'
|
||||
im = mapnik.Image.open(expected)
|
||||
t0 = tmp_dir + 'png-encoding-9-colors.result-hextree.png'
|
||||
im.save(t0, 'png8:m=h')
|
||||
eq_(mapnik.Image.open(t0).tostring(),
|
||||
mapnik.Image.open(expected).tostring(),
|
||||
'%s (actual) not == to %s (expected)' % (t0, expected))
|
||||
|
||||
def test_9_colors_octree():
|
||||
expected = './images/support/encoding-opts/png8-9cols.png'
|
||||
im = mapnik.Image.open(expected)
|
||||
t0 = tmp_dir + 'png-encoding-9-colors.result-octree.png'
|
||||
im.save(t0, 'png8:m=o')
|
||||
eq_(mapnik.Image.open(t0).tostring(),
|
||||
mapnik.Image.open(expected).tostring(),
|
||||
'%s (actual) not == to %s (expected)' % (t0, expected))
|
||||
|
||||
def test_17_colors_hextree():
|
||||
expected = './images/support/encoding-opts/png8-17cols.png'
|
||||
im = mapnik.Image.open(expected)
|
||||
t0 = tmp_dir + 'png-encoding-17-colors.result-hextree.png'
|
||||
im.save(t0, 'png8:m=h')
|
||||
eq_(mapnik.Image.open(t0).tostring(),
|
||||
mapnik.Image.open(expected).tostring(),
|
||||
'%s (actual) not == to %s (expected)' % (t0, expected))
|
||||
|
||||
def test_17_colors_octree():
|
||||
expected = './images/support/encoding-opts/png8-17cols.png'
|
||||
im = mapnik.Image.open(expected)
|
||||
t0 = tmp_dir + 'png-encoding-17-colors.result-octree.png'
|
||||
im.save(t0, 'png8:m=o')
|
||||
eq_(mapnik.Image.open(t0).tostring(),
|
||||
mapnik.Image.open(expected).tostring(),
|
||||
'%s (actual) not == to %s (expected)' % (t0, expected))
|
||||
|
||||
def test_2px_regression_hextree():
|
||||
im = mapnik.Image.open('./images/support/encoding-opts/png8-2px.A.png')
|
||||
expected = './images/support/encoding-opts/png8-2px.png'
|
||||
|
||||
t0 = tmp_dir + 'png-encoding-2px.result-hextree.png'
|
||||
im.save(t0, 'png8:m=h')
|
||||
eq_(mapnik.Image.open(t0).tostring(),
|
||||
mapnik.Image.open(expected).tostring(),
|
||||
'%s (actual) not == to %s (expected)' % (t0, expected))
|
||||
|
||||
def test_2px_regression_octree():
|
||||
im = mapnik.Image.open('./images/support/encoding-opts/png8-2px.A.png')
|
||||
expected = './images/support/encoding-opts/png8-2px.png'
|
||||
t0 = tmp_dir + 'png-encoding-2px.result-octree.png'
|
||||
im.save(t0, 'png8:m=o')
|
||||
eq_(mapnik.Image.open(t0).tostring(),
|
||||
mapnik.Image.open(expected).tostring(),
|
||||
'%s (actual) not == to %s (expected)' % (t0, expected))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup()
|
||||
exit(run_all(eval(x) for x in dir() if x.startswith("test_")))
|
||||
|
|
Loading…
Reference in a new issue