Commit c6e84d4
committed
pdf: Use explicit palette when saving indexed images
Asking Pillow for an "adaptive palette" does not appear to guarantee
that the chosen colours will be the same, even if asking for exactly the
same number as exist in the image. Instead, create an explicit palette,
and quantize using it.
Additionally, since now the palette may be smaller than 256 colours,
Pillow may choose to encode the image data with fewer than 8 bits per
component, so we need to properly reflect that in the decode parameters
(this was already done for the image parameters).
The effect on test images with _many_ colours is small, with a maximum
RMS of 1.024, but for images with few colours, the result can be
completely wrong as in the reported #25806.1 parent 5a89bdb commit c6e84d4
File tree
21 files changed
+15
-21
lines changed- lib/matplotlib
- backends
- tests
- baseline_images
- test_agg_filter
- test_axes
- test_backend_pdf
- test_image
- test_patheffects
- test_streamplot
- test_tightlayout
21 files changed
+15
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1730 | 1730 | | |
1731 | 1731 | | |
1732 | 1732 | | |
1733 | | - | |
1734 | | - | |
| 1733 | + | |
1735 | 1734 | | |
1736 | 1735 | | |
1737 | 1736 | | |
1738 | 1737 | | |
1739 | 1738 | | |
1740 | 1739 | | |
| 1740 | + | |
1741 | 1741 | | |
1742 | 1742 | | |
1743 | 1743 | | |
1744 | 1744 | | |
1745 | 1745 | | |
1746 | 1746 | | |
1747 | | - | |
1748 | | - | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
1749 | 1752 | | |
1750 | | - | |
1751 | | - | |
1752 | | - | |
1753 | | - | |
| 1753 | + | |
1754 | 1754 | | |
1755 | 1755 | | |
1756 | 1756 | | |
1757 | | - | |
1758 | | - | |
1759 | | - | |
1760 | | - | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
1761 | 1760 | | |
1762 | | - | |
| 1761 | + | |
| 1762 | + | |
1763 | 1763 | | |
1764 | 1764 | | |
1765 | | - | |
1766 | 1765 | | |
1767 | 1766 | | |
1768 | 1767 | | |
| |||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 commit comments