@ai-ecoverse/py-pillow 12.3.0-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +30 -0
- package/README.md +4 -0
- package/lib/python3.14/site-packages/PIL/AvifImagePlugin.py +295 -0
- package/lib/python3.14/site-packages/PIL/BdfFontFile.py +124 -0
- package/lib/python3.14/site-packages/PIL/BlpImagePlugin.py +498 -0
- package/lib/python3.14/site-packages/PIL/BmpImagePlugin.py +514 -0
- package/lib/python3.14/site-packages/PIL/BufrStubImagePlugin.py +72 -0
- package/lib/python3.14/site-packages/PIL/ContainerIO.py +173 -0
- package/lib/python3.14/site-packages/PIL/CurImagePlugin.py +103 -0
- package/lib/python3.14/site-packages/PIL/DcxImagePlugin.py +84 -0
- package/lib/python3.14/site-packages/PIL/DdsImagePlugin.py +632 -0
- package/lib/python3.14/site-packages/PIL/EpsImagePlugin.py +484 -0
- package/lib/python3.14/site-packages/PIL/ExifTags.py +384 -0
- package/lib/python3.14/site-packages/PIL/FitsImagePlugin.py +153 -0
- package/lib/python3.14/site-packages/PIL/FliImagePlugin.py +184 -0
- package/lib/python3.14/site-packages/PIL/FontFile.py +160 -0
- package/lib/python3.14/site-packages/PIL/FpxImagePlugin.py +262 -0
- package/lib/python3.14/site-packages/PIL/FtexImagePlugin.py +115 -0
- package/lib/python3.14/site-packages/PIL/GbrImagePlugin.py +103 -0
- package/lib/python3.14/site-packages/PIL/GdImageFile.py +104 -0
- package/lib/python3.14/site-packages/PIL/GifImagePlugin.py +1223 -0
- package/lib/python3.14/site-packages/PIL/GimpGradientFile.py +154 -0
- package/lib/python3.14/site-packages/PIL/GimpPaletteFile.py +75 -0
- package/lib/python3.14/site-packages/PIL/GribStubImagePlugin.py +72 -0
- package/lib/python3.14/site-packages/PIL/Hdf5StubImagePlugin.py +72 -0
- package/lib/python3.14/site-packages/PIL/IcnsImagePlugin.py +401 -0
- package/lib/python3.14/site-packages/PIL/IcoImagePlugin.py +396 -0
- package/lib/python3.14/site-packages/PIL/ImImagePlugin.py +390 -0
- package/lib/python3.14/site-packages/PIL/Image.py +4385 -0
- package/lib/python3.14/site-packages/PIL/ImageChops.py +311 -0
- package/lib/python3.14/site-packages/PIL/ImageCms.py +1078 -0
- package/lib/python3.14/site-packages/PIL/ImageColor.py +320 -0
- package/lib/python3.14/site-packages/PIL/ImageDraw.py +1002 -0
- package/lib/python3.14/site-packages/PIL/ImageDraw2.py +244 -0
- package/lib/python3.14/site-packages/PIL/ImageEnhance.py +113 -0
- package/lib/python3.14/site-packages/PIL/ImageFile.py +938 -0
- package/lib/python3.14/site-packages/PIL/ImageFilter.py +617 -0
- package/lib/python3.14/site-packages/PIL/ImageFont.py +1330 -0
- package/lib/python3.14/site-packages/PIL/ImageGrab.py +234 -0
- package/lib/python3.14/site-packages/PIL/ImageMath.py +314 -0
- package/lib/python3.14/site-packages/PIL/ImageMode.py +85 -0
- package/lib/python3.14/site-packages/PIL/ImageMorph.py +317 -0
- package/lib/python3.14/site-packages/PIL/ImageOps.py +749 -0
- package/lib/python3.14/site-packages/PIL/ImagePalette.py +290 -0
- package/lib/python3.14/site-packages/PIL/ImagePath.py +20 -0
- package/lib/python3.14/site-packages/PIL/ImageQt.py +219 -0
- package/lib/python3.14/site-packages/PIL/ImageSequence.py +88 -0
- package/lib/python3.14/site-packages/PIL/ImageShow.py +367 -0
- package/lib/python3.14/site-packages/PIL/ImageStat.py +167 -0
- package/lib/python3.14/site-packages/PIL/ImageText.py +509 -0
- package/lib/python3.14/site-packages/PIL/ImageTk.py +266 -0
- package/lib/python3.14/site-packages/PIL/ImageTransform.py +136 -0
- package/lib/python3.14/site-packages/PIL/ImageWin.py +247 -0
- package/lib/python3.14/site-packages/PIL/ImtImagePlugin.py +103 -0
- package/lib/python3.14/site-packages/PIL/IptcImagePlugin.py +226 -0
- package/lib/python3.14/site-packages/PIL/Jpeg2KImagePlugin.py +466 -0
- package/lib/python3.14/site-packages/PIL/JpegImagePlugin.py +889 -0
- package/lib/python3.14/site-packages/PIL/JpegPresets.py +242 -0
- package/lib/python3.14/site-packages/PIL/McIdasImagePlugin.py +78 -0
- package/lib/python3.14/site-packages/PIL/MicImagePlugin.py +103 -0
- package/lib/python3.14/site-packages/PIL/MpegImagePlugin.py +84 -0
- package/lib/python3.14/site-packages/PIL/MpoImagePlugin.py +203 -0
- package/lib/python3.14/site-packages/PIL/MspImagePlugin.py +200 -0
- package/lib/python3.14/site-packages/PIL/PSDraw.py +238 -0
- package/lib/python3.14/site-packages/PIL/PaletteFile.py +54 -0
- package/lib/python3.14/site-packages/PIL/PalmImagePlugin.py +217 -0
- package/lib/python3.14/site-packages/PIL/PcdImagePlugin.py +68 -0
- package/lib/python3.14/site-packages/PIL/PcfFontFile.py +256 -0
- package/lib/python3.14/site-packages/PIL/PcxImagePlugin.py +232 -0
- package/lib/python3.14/site-packages/PIL/PdfImagePlugin.py +315 -0
- package/lib/python3.14/site-packages/PIL/PdfParser.py +1092 -0
- package/lib/python3.14/site-packages/PIL/PixarImagePlugin.py +72 -0
- package/lib/python3.14/site-packages/PIL/PngImagePlugin.py +1578 -0
- package/lib/python3.14/site-packages/PIL/PpmImagePlugin.py +375 -0
- package/lib/python3.14/site-packages/PIL/PsdImagePlugin.py +339 -0
- package/lib/python3.14/site-packages/PIL/QoiImagePlugin.py +235 -0
- package/lib/python3.14/site-packages/PIL/SgiImagePlugin.py +231 -0
- package/lib/python3.14/site-packages/PIL/SpiderImagePlugin.py +332 -0
- package/lib/python3.14/site-packages/PIL/SunImagePlugin.py +145 -0
- package/lib/python3.14/site-packages/PIL/TarIO.py +61 -0
- package/lib/python3.14/site-packages/PIL/TgaImagePlugin.py +284 -0
- package/lib/python3.14/site-packages/PIL/TiffImagePlugin.py +2354 -0
- package/lib/python3.14/site-packages/PIL/TiffTags.py +566 -0
- package/lib/python3.14/site-packages/PIL/WalImageFile.py +129 -0
- package/lib/python3.14/site-packages/PIL/WebPImagePlugin.py +322 -0
- package/lib/python3.14/site-packages/PIL/WmfImagePlugin.py +183 -0
- package/lib/python3.14/site-packages/PIL/XVThumbImagePlugin.py +83 -0
- package/lib/python3.14/site-packages/PIL/XbmImagePlugin.py +98 -0
- package/lib/python3.14/site-packages/PIL/XpmImagePlugin.py +157 -0
- package/lib/python3.14/site-packages/PIL/__init__.py +87 -0
- package/lib/python3.14/site-packages/PIL/__main__.py +7 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/AvifImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/BdfFontFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/BlpImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/BmpImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/BufrStubImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ContainerIO.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/CurImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/DcxImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/DdsImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/EpsImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ExifTags.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/FitsImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/FliImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/FontFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/FpxImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/FtexImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GbrImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GdImageFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GifImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GimpGradientFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GimpPaletteFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/GribStubImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/Hdf5StubImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/IcnsImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/IcoImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/Image.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageChops.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageCms.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageColor.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageDraw.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageDraw2.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageEnhance.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageFilter.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageFont.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageGrab.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageMath.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageMode.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageMorph.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageOps.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImagePalette.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImagePath.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageQt.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageSequence.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageShow.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageStat.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageText.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageTk.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageTransform.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImageWin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/ImtImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/IptcImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/Jpeg2KImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/JpegImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/JpegPresets.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/McIdasImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/MicImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/MpegImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/MpoImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/MspImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PSDraw.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PaletteFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PalmImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PcdImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PcfFontFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PcxImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PdfImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PdfParser.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PixarImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PngImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PpmImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/PsdImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/QoiImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/SgiImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/SpiderImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/SunImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/TarIO.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/TgaImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/TiffImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/TiffTags.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/WalImageFile.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/WebPImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/WmfImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/XVThumbImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/XbmImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/XpmImagePlugin.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/__init__.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/__main__.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_binary.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_deprecate.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_tkinter_finder.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_typing.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_util.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/_version.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/features.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/__pycache__/report.cpython-314.pyc +0 -0
- package/lib/python3.14/site-packages/PIL/_avif.pyi +3 -0
- package/lib/python3.14/site-packages/PIL/_binary.py +113 -0
- package/lib/python3.14/site-packages/PIL/_deprecate.py +72 -0
- package/lib/python3.14/site-packages/PIL/_imaging.cpython-314-wasm32-wasix.so +0 -0
- package/lib/python3.14/site-packages/PIL/_imaging.pyi +31 -0
- package/lib/python3.14/site-packages/PIL/_imagingcms.pyi +143 -0
- package/lib/python3.14/site-packages/PIL/_imagingft.cpython-314-wasm32-wasix.so +0 -0
- package/lib/python3.14/site-packages/PIL/_imagingft.pyi +70 -0
- package/lib/python3.14/site-packages/PIL/_imagingmath.cpython-314-wasm32-wasix.so +0 -0
- package/lib/python3.14/site-packages/PIL/_imagingmath.pyi +3 -0
- package/lib/python3.14/site-packages/PIL/_imagingmorph.cpython-314-wasm32-wasix.so +0 -0
- package/lib/python3.14/site-packages/PIL/_imagingmorph.pyi +3 -0
- package/lib/python3.14/site-packages/PIL/_imagingtk.cpython-314-wasm32-wasix.so +0 -0
- package/lib/python3.14/site-packages/PIL/_imagingtk.pyi +3 -0
- package/lib/python3.14/site-packages/PIL/_tkinter_finder.py +20 -0
- package/lib/python3.14/site-packages/PIL/_typing.py +45 -0
- package/lib/python3.14/site-packages/PIL/_util.py +29 -0
- package/lib/python3.14/site-packages/PIL/_version.py +4 -0
- package/lib/python3.14/site-packages/PIL/_webp.pyi +3 -0
- package/lib/python3.14/site-packages/PIL/features.py +343 -0
- package/lib/python3.14/site-packages/PIL/py.typed +0 -0
- package/lib/python3.14/site-packages/PIL/report.py +5 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/METADATA +180 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/RECORD +117 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/WHEEL +5 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/licenses/LICENSE +30 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/top_level.txt +1 -0
- package/lib/python3.14/site-packages/pillow-12.3.0.dist-info/zip-safe +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
#
|
|
2
|
+
# The Python Imaging Library.
|
|
3
|
+
# $Id$
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
##
|
|
7
|
+
# Image plugin for Palm pixmap images (output only).
|
|
8
|
+
##
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from typing import IO
|
|
12
|
+
|
|
13
|
+
from . import Image, ImageFile
|
|
14
|
+
from ._binary import o8
|
|
15
|
+
from ._binary import o16be as o16b
|
|
16
|
+
|
|
17
|
+
# fmt: off
|
|
18
|
+
_Palm8BitColormapValues = (
|
|
19
|
+
(255, 255, 255), (255, 204, 255), (255, 153, 255), (255, 102, 255),
|
|
20
|
+
(255, 51, 255), (255, 0, 255), (255, 255, 204), (255, 204, 204),
|
|
21
|
+
(255, 153, 204), (255, 102, 204), (255, 51, 204), (255, 0, 204),
|
|
22
|
+
(255, 255, 153), (255, 204, 153), (255, 153, 153), (255, 102, 153),
|
|
23
|
+
(255, 51, 153), (255, 0, 153), (204, 255, 255), (204, 204, 255),
|
|
24
|
+
(204, 153, 255), (204, 102, 255), (204, 51, 255), (204, 0, 255),
|
|
25
|
+
(204, 255, 204), (204, 204, 204), (204, 153, 204), (204, 102, 204),
|
|
26
|
+
(204, 51, 204), (204, 0, 204), (204, 255, 153), (204, 204, 153),
|
|
27
|
+
(204, 153, 153), (204, 102, 153), (204, 51, 153), (204, 0, 153),
|
|
28
|
+
(153, 255, 255), (153, 204, 255), (153, 153, 255), (153, 102, 255),
|
|
29
|
+
(153, 51, 255), (153, 0, 255), (153, 255, 204), (153, 204, 204),
|
|
30
|
+
(153, 153, 204), (153, 102, 204), (153, 51, 204), (153, 0, 204),
|
|
31
|
+
(153, 255, 153), (153, 204, 153), (153, 153, 153), (153, 102, 153),
|
|
32
|
+
(153, 51, 153), (153, 0, 153), (102, 255, 255), (102, 204, 255),
|
|
33
|
+
(102, 153, 255), (102, 102, 255), (102, 51, 255), (102, 0, 255),
|
|
34
|
+
(102, 255, 204), (102, 204, 204), (102, 153, 204), (102, 102, 204),
|
|
35
|
+
(102, 51, 204), (102, 0, 204), (102, 255, 153), (102, 204, 153),
|
|
36
|
+
(102, 153, 153), (102, 102, 153), (102, 51, 153), (102, 0, 153),
|
|
37
|
+
(51, 255, 255), (51, 204, 255), (51, 153, 255), (51, 102, 255),
|
|
38
|
+
(51, 51, 255), (51, 0, 255), (51, 255, 204), (51, 204, 204),
|
|
39
|
+
(51, 153, 204), (51, 102, 204), (51, 51, 204), (51, 0, 204),
|
|
40
|
+
(51, 255, 153), (51, 204, 153), (51, 153, 153), (51, 102, 153),
|
|
41
|
+
(51, 51, 153), (51, 0, 153), (0, 255, 255), (0, 204, 255),
|
|
42
|
+
(0, 153, 255), (0, 102, 255), (0, 51, 255), (0, 0, 255),
|
|
43
|
+
(0, 255, 204), (0, 204, 204), (0, 153, 204), (0, 102, 204),
|
|
44
|
+
(0, 51, 204), (0, 0, 204), (0, 255, 153), (0, 204, 153),
|
|
45
|
+
(0, 153, 153), (0, 102, 153), (0, 51, 153), (0, 0, 153),
|
|
46
|
+
(255, 255, 102), (255, 204, 102), (255, 153, 102), (255, 102, 102),
|
|
47
|
+
(255, 51, 102), (255, 0, 102), (255, 255, 51), (255, 204, 51),
|
|
48
|
+
(255, 153, 51), (255, 102, 51), (255, 51, 51), (255, 0, 51),
|
|
49
|
+
(255, 255, 0), (255, 204, 0), (255, 153, 0), (255, 102, 0),
|
|
50
|
+
(255, 51, 0), (255, 0, 0), (204, 255, 102), (204, 204, 102),
|
|
51
|
+
(204, 153, 102), (204, 102, 102), (204, 51, 102), (204, 0, 102),
|
|
52
|
+
(204, 255, 51), (204, 204, 51), (204, 153, 51), (204, 102, 51),
|
|
53
|
+
(204, 51, 51), (204, 0, 51), (204, 255, 0), (204, 204, 0),
|
|
54
|
+
(204, 153, 0), (204, 102, 0), (204, 51, 0), (204, 0, 0),
|
|
55
|
+
(153, 255, 102), (153, 204, 102), (153, 153, 102), (153, 102, 102),
|
|
56
|
+
(153, 51, 102), (153, 0, 102), (153, 255, 51), (153, 204, 51),
|
|
57
|
+
(153, 153, 51), (153, 102, 51), (153, 51, 51), (153, 0, 51),
|
|
58
|
+
(153, 255, 0), (153, 204, 0), (153, 153, 0), (153, 102, 0),
|
|
59
|
+
(153, 51, 0), (153, 0, 0), (102, 255, 102), (102, 204, 102),
|
|
60
|
+
(102, 153, 102), (102, 102, 102), (102, 51, 102), (102, 0, 102),
|
|
61
|
+
(102, 255, 51), (102, 204, 51), (102, 153, 51), (102, 102, 51),
|
|
62
|
+
(102, 51, 51), (102, 0, 51), (102, 255, 0), (102, 204, 0),
|
|
63
|
+
(102, 153, 0), (102, 102, 0), (102, 51, 0), (102, 0, 0),
|
|
64
|
+
(51, 255, 102), (51, 204, 102), (51, 153, 102), (51, 102, 102),
|
|
65
|
+
(51, 51, 102), (51, 0, 102), (51, 255, 51), (51, 204, 51),
|
|
66
|
+
(51, 153, 51), (51, 102, 51), (51, 51, 51), (51, 0, 51),
|
|
67
|
+
(51, 255, 0), (51, 204, 0), (51, 153, 0), (51, 102, 0),
|
|
68
|
+
(51, 51, 0), (51, 0, 0), (0, 255, 102), (0, 204, 102),
|
|
69
|
+
(0, 153, 102), (0, 102, 102), (0, 51, 102), (0, 0, 102),
|
|
70
|
+
(0, 255, 51), (0, 204, 51), (0, 153, 51), (0, 102, 51),
|
|
71
|
+
(0, 51, 51), (0, 0, 51), (0, 255, 0), (0, 204, 0),
|
|
72
|
+
(0, 153, 0), (0, 102, 0), (0, 51, 0), (17, 17, 17),
|
|
73
|
+
(34, 34, 34), (68, 68, 68), (85, 85, 85), (119, 119, 119),
|
|
74
|
+
(136, 136, 136), (170, 170, 170), (187, 187, 187), (221, 221, 221),
|
|
75
|
+
(238, 238, 238), (192, 192, 192), (128, 0, 0), (128, 0, 128),
|
|
76
|
+
(0, 128, 0), (0, 128, 128), (0, 0, 0), (0, 0, 0),
|
|
77
|
+
(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
|
|
78
|
+
(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
|
|
79
|
+
(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
|
|
80
|
+
(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
|
|
81
|
+
(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
|
|
82
|
+
(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0))
|
|
83
|
+
# fmt: on
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# so build a prototype image to be used for palette resampling
|
|
87
|
+
def build_prototype_image() -> Image.Image:
|
|
88
|
+
image = Image.new("L", (1, len(_Palm8BitColormapValues)))
|
|
89
|
+
image.putdata(list(range(len(_Palm8BitColormapValues))))
|
|
90
|
+
palettedata: tuple[int, ...] = ()
|
|
91
|
+
for colormapValue in _Palm8BitColormapValues:
|
|
92
|
+
palettedata += colormapValue
|
|
93
|
+
palettedata += (0, 0, 0) * (256 - len(_Palm8BitColormapValues))
|
|
94
|
+
image.putpalette(palettedata)
|
|
95
|
+
return image
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
Palm8BitColormapImage = build_prototype_image()
|
|
99
|
+
|
|
100
|
+
# OK, we now have in Palm8BitColormapImage,
|
|
101
|
+
# a "P"-mode image with the right palette
|
|
102
|
+
#
|
|
103
|
+
# --------------------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
_FLAGS = {"custom-colormap": 0x4000, "is-compressed": 0x8000, "has-transparent": 0x2000}
|
|
106
|
+
|
|
107
|
+
_COMPRESSION_TYPES = {"none": 0xFF, "rle": 0x01, "scanline": 0x00}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
#
|
|
111
|
+
# --------------------------------------------------------------------
|
|
112
|
+
|
|
113
|
+
##
|
|
114
|
+
# (Internal) Image save plugin for the Palm format.
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
|
118
|
+
if im.mode == "P":
|
|
119
|
+
rawmode = "P"
|
|
120
|
+
bpp = 8
|
|
121
|
+
version = 1
|
|
122
|
+
|
|
123
|
+
elif im.mode == "L":
|
|
124
|
+
if im.encoderinfo.get("bpp") in (1, 2, 4):
|
|
125
|
+
# this is 8-bit grayscale, so we shift it to get the high-order bits,
|
|
126
|
+
# and invert it because
|
|
127
|
+
# Palm does grayscale from white (0) to black (1)
|
|
128
|
+
bpp = im.encoderinfo["bpp"]
|
|
129
|
+
maxval = (1 << bpp) - 1
|
|
130
|
+
shift = 8 - bpp
|
|
131
|
+
im = im.point(lambda x: maxval - (x >> shift))
|
|
132
|
+
elif im.info.get("bpp") in (1, 2, 4):
|
|
133
|
+
# here we assume that even though the inherent mode is 8-bit grayscale,
|
|
134
|
+
# only the lower bpp bits are significant.
|
|
135
|
+
# We invert them to match the Palm.
|
|
136
|
+
bpp = im.info["bpp"]
|
|
137
|
+
maxval = (1 << bpp) - 1
|
|
138
|
+
im = im.point(lambda x: maxval - (x & maxval))
|
|
139
|
+
else:
|
|
140
|
+
msg = f"cannot write mode {im.mode} as Palm"
|
|
141
|
+
raise OSError(msg)
|
|
142
|
+
|
|
143
|
+
# we ignore the palette here
|
|
144
|
+
im._mode = "P"
|
|
145
|
+
rawmode = f"P;{bpp}"
|
|
146
|
+
version = 1
|
|
147
|
+
|
|
148
|
+
elif im.mode == "1":
|
|
149
|
+
# monochrome -- write it inverted, as is the Palm standard
|
|
150
|
+
rawmode = "1;I"
|
|
151
|
+
bpp = 1
|
|
152
|
+
version = 0
|
|
153
|
+
|
|
154
|
+
else:
|
|
155
|
+
msg = f"cannot write mode {im.mode} as Palm"
|
|
156
|
+
raise OSError(msg)
|
|
157
|
+
|
|
158
|
+
#
|
|
159
|
+
# make sure image data is available
|
|
160
|
+
im.load()
|
|
161
|
+
|
|
162
|
+
# write header
|
|
163
|
+
|
|
164
|
+
cols = im.size[0]
|
|
165
|
+
rows = im.size[1]
|
|
166
|
+
|
|
167
|
+
rowbytes = int((cols + (16 // bpp - 1)) / (16 // bpp)) * 2
|
|
168
|
+
transparent_index = 0
|
|
169
|
+
compression_type = _COMPRESSION_TYPES["none"]
|
|
170
|
+
|
|
171
|
+
flags = 0
|
|
172
|
+
if im.mode == "P":
|
|
173
|
+
flags |= _FLAGS["custom-colormap"]
|
|
174
|
+
colormap = im.im.getpalette()
|
|
175
|
+
colors = len(colormap) // 3
|
|
176
|
+
colormapsize = 4 * colors + 2
|
|
177
|
+
else:
|
|
178
|
+
colormapsize = 0
|
|
179
|
+
|
|
180
|
+
if "offset" in im.info:
|
|
181
|
+
offset = (rowbytes * rows + 16 + 3 + colormapsize) // 4
|
|
182
|
+
else:
|
|
183
|
+
offset = 0
|
|
184
|
+
|
|
185
|
+
fp.write(o16b(cols) + o16b(rows) + o16b(rowbytes) + o16b(flags))
|
|
186
|
+
fp.write(o8(bpp))
|
|
187
|
+
fp.write(o8(version))
|
|
188
|
+
fp.write(o16b(offset))
|
|
189
|
+
fp.write(o8(transparent_index))
|
|
190
|
+
fp.write(o8(compression_type))
|
|
191
|
+
fp.write(o16b(0)) # reserved by Palm
|
|
192
|
+
|
|
193
|
+
# now write colormap if necessary
|
|
194
|
+
|
|
195
|
+
if colormapsize:
|
|
196
|
+
fp.write(o16b(colors))
|
|
197
|
+
for i in range(colors):
|
|
198
|
+
fp.write(o8(i))
|
|
199
|
+
fp.write(colormap[3 * i : 3 * i + 3])
|
|
200
|
+
|
|
201
|
+
# now convert data to raw form
|
|
202
|
+
ImageFile._save(
|
|
203
|
+
im, fp, [ImageFile._Tile("raw", (0, 0) + im.size, 0, (rawmode, rowbytes, 1))]
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
if hasattr(fp, "flush"):
|
|
207
|
+
fp.flush()
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
#
|
|
211
|
+
# --------------------------------------------------------------------
|
|
212
|
+
|
|
213
|
+
Image.register_save("PALM", _save)
|
|
214
|
+
|
|
215
|
+
Image.register_extension("PALM", ".palm")
|
|
216
|
+
|
|
217
|
+
Image.register_mime("PALM", "image/palm")
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#
|
|
2
|
+
# The Python Imaging Library.
|
|
3
|
+
# $Id$
|
|
4
|
+
#
|
|
5
|
+
# PCD file handling
|
|
6
|
+
#
|
|
7
|
+
# History:
|
|
8
|
+
# 96-05-10 fl Created
|
|
9
|
+
# 96-05-27 fl Added draft mode (128x192, 256x384)
|
|
10
|
+
#
|
|
11
|
+
# Copyright (c) Secret Labs AB 1997.
|
|
12
|
+
# Copyright (c) Fredrik Lundh 1996.
|
|
13
|
+
#
|
|
14
|
+
# See the README file for information on usage and redistribution.
|
|
15
|
+
#
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from . import Image, ImageFile
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
# Image plugin for PhotoCD images. This plugin only reads the 768x512
|
|
22
|
+
# image from the file; higher resolutions are encoded in a proprietary
|
|
23
|
+
# encoding.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class PcdImageFile(ImageFile.ImageFile):
|
|
27
|
+
format = "PCD"
|
|
28
|
+
format_description = "Kodak PhotoCD"
|
|
29
|
+
|
|
30
|
+
def _open(self) -> None:
|
|
31
|
+
# rough
|
|
32
|
+
assert self.fp is not None
|
|
33
|
+
|
|
34
|
+
self.fp.seek(2048)
|
|
35
|
+
s = self.fp.read(1539)
|
|
36
|
+
|
|
37
|
+
if not s.startswith(b"PCD_"):
|
|
38
|
+
msg = "not a PCD file"
|
|
39
|
+
raise SyntaxError(msg)
|
|
40
|
+
|
|
41
|
+
orientation = s[1538] & 3
|
|
42
|
+
self.tile_post_rotate = None
|
|
43
|
+
if orientation == 1:
|
|
44
|
+
self.tile_post_rotate = 90
|
|
45
|
+
elif orientation == 3:
|
|
46
|
+
self.tile_post_rotate = 270
|
|
47
|
+
|
|
48
|
+
self._mode = "RGB"
|
|
49
|
+
self._size = (512, 768) if orientation in (1, 3) else (768, 512)
|
|
50
|
+
self.tile = [ImageFile._Tile("pcd", (0, 0, 768, 512), 96 * 2048)]
|
|
51
|
+
|
|
52
|
+
def load_prepare(self) -> None:
|
|
53
|
+
if self._im is None and self.tile_post_rotate:
|
|
54
|
+
self.im = Image.core.new(self.mode, (768, 512))
|
|
55
|
+
ImageFile.ImageFile.load_prepare(self)
|
|
56
|
+
|
|
57
|
+
def load_end(self) -> None:
|
|
58
|
+
if self.tile_post_rotate:
|
|
59
|
+
# Handle rotated PCDs
|
|
60
|
+
self.im = self.rotate(self.tile_post_rotate, expand=True).im
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
#
|
|
64
|
+
# registry
|
|
65
|
+
|
|
66
|
+
Image.register_open(PcdImageFile.format, PcdImageFile)
|
|
67
|
+
|
|
68
|
+
Image.register_extension(PcdImageFile.format, ".pcd")
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
#
|
|
2
|
+
# THIS IS WORK IN PROGRESS
|
|
3
|
+
#
|
|
4
|
+
# The Python Imaging Library
|
|
5
|
+
# $Id$
|
|
6
|
+
#
|
|
7
|
+
# portable compiled font file parser
|
|
8
|
+
#
|
|
9
|
+
# history:
|
|
10
|
+
# 1997-08-19 fl created
|
|
11
|
+
# 2003-09-13 fl fixed loading of unicode fonts
|
|
12
|
+
#
|
|
13
|
+
# Copyright (c) 1997-2003 by Secret Labs AB.
|
|
14
|
+
# Copyright (c) 1997-2003 by Fredrik Lundh.
|
|
15
|
+
#
|
|
16
|
+
# See the README file for information on usage and redistribution.
|
|
17
|
+
#
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import io
|
|
21
|
+
|
|
22
|
+
from . import FontFile, Image
|
|
23
|
+
from ._binary import i8
|
|
24
|
+
from ._binary import i16be as b16
|
|
25
|
+
from ._binary import i16le as l16
|
|
26
|
+
from ._binary import i32be as b32
|
|
27
|
+
from ._binary import i32le as l32
|
|
28
|
+
|
|
29
|
+
TYPE_CHECKING = False
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
from collections.abc import Callable
|
|
32
|
+
from typing import BinaryIO
|
|
33
|
+
|
|
34
|
+
# --------------------------------------------------------------------
|
|
35
|
+
# declarations
|
|
36
|
+
|
|
37
|
+
PCF_MAGIC = 0x70636601 # "\x01fcp"
|
|
38
|
+
|
|
39
|
+
PCF_PROPERTIES = 1 << 0
|
|
40
|
+
PCF_ACCELERATORS = 1 << 1
|
|
41
|
+
PCF_METRICS = 1 << 2
|
|
42
|
+
PCF_BITMAPS = 1 << 3
|
|
43
|
+
PCF_INK_METRICS = 1 << 4
|
|
44
|
+
PCF_BDF_ENCODINGS = 1 << 5
|
|
45
|
+
PCF_SWIDTHS = 1 << 6
|
|
46
|
+
PCF_GLYPH_NAMES = 1 << 7
|
|
47
|
+
PCF_BDF_ACCELERATORS = 1 << 8
|
|
48
|
+
|
|
49
|
+
BYTES_PER_ROW: list[Callable[[int], int]] = [
|
|
50
|
+
lambda bits: ((bits + 7) >> 3),
|
|
51
|
+
lambda bits: ((bits + 15) >> 3) & ~1,
|
|
52
|
+
lambda bits: ((bits + 31) >> 3) & ~3,
|
|
53
|
+
lambda bits: ((bits + 63) >> 3) & ~7,
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def sz(s: bytes, o: int) -> bytes:
|
|
58
|
+
return s[o : s.index(b"\0", o)]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class PcfFontFile(FontFile.FontFile):
|
|
62
|
+
"""Font file plugin for the X11 PCF format."""
|
|
63
|
+
|
|
64
|
+
name = "name"
|
|
65
|
+
|
|
66
|
+
def __init__(self, fp: BinaryIO, charset_encoding: str = "iso8859-1"):
|
|
67
|
+
self.charset_encoding = charset_encoding
|
|
68
|
+
|
|
69
|
+
magic = l32(fp.read(4))
|
|
70
|
+
if magic != PCF_MAGIC:
|
|
71
|
+
msg = "not a PCF file"
|
|
72
|
+
raise SyntaxError(msg)
|
|
73
|
+
|
|
74
|
+
super().__init__()
|
|
75
|
+
|
|
76
|
+
count = l32(fp.read(4))
|
|
77
|
+
self.toc = {}
|
|
78
|
+
for i in range(count):
|
|
79
|
+
type = l32(fp.read(4))
|
|
80
|
+
self.toc[type] = l32(fp.read(4)), l32(fp.read(4)), l32(fp.read(4))
|
|
81
|
+
|
|
82
|
+
self.fp = fp
|
|
83
|
+
|
|
84
|
+
self.info = self._load_properties()
|
|
85
|
+
|
|
86
|
+
metrics = self._load_metrics()
|
|
87
|
+
bitmaps = self._load_bitmaps(metrics)
|
|
88
|
+
encoding = self._load_encoding()
|
|
89
|
+
|
|
90
|
+
#
|
|
91
|
+
# create glyph structure
|
|
92
|
+
|
|
93
|
+
for ch, ix in enumerate(encoding):
|
|
94
|
+
if ix is not None:
|
|
95
|
+
(
|
|
96
|
+
xsize,
|
|
97
|
+
ysize,
|
|
98
|
+
left,
|
|
99
|
+
right,
|
|
100
|
+
width,
|
|
101
|
+
ascent,
|
|
102
|
+
descent,
|
|
103
|
+
attributes,
|
|
104
|
+
) = metrics[ix]
|
|
105
|
+
self.glyph[ch] = (
|
|
106
|
+
(width, 0),
|
|
107
|
+
(left, descent - ysize, xsize + left, descent),
|
|
108
|
+
(0, 0, xsize, ysize),
|
|
109
|
+
bitmaps[ix],
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def _getformat(
|
|
113
|
+
self, tag: int
|
|
114
|
+
) -> tuple[BinaryIO, int, Callable[[bytes], int], Callable[[bytes], int]]:
|
|
115
|
+
format, size, offset = self.toc[tag]
|
|
116
|
+
|
|
117
|
+
fp = self.fp
|
|
118
|
+
fp.seek(offset)
|
|
119
|
+
|
|
120
|
+
format = l32(fp.read(4))
|
|
121
|
+
|
|
122
|
+
if format & 4:
|
|
123
|
+
i16, i32 = b16, b32
|
|
124
|
+
else:
|
|
125
|
+
i16, i32 = l16, l32
|
|
126
|
+
|
|
127
|
+
return fp, format, i16, i32
|
|
128
|
+
|
|
129
|
+
def _load_properties(self) -> dict[bytes, bytes | int]:
|
|
130
|
+
#
|
|
131
|
+
# font properties
|
|
132
|
+
|
|
133
|
+
properties = {}
|
|
134
|
+
|
|
135
|
+
fp, format, i16, i32 = self._getformat(PCF_PROPERTIES)
|
|
136
|
+
|
|
137
|
+
nprops = i32(fp.read(4))
|
|
138
|
+
|
|
139
|
+
# read property description
|
|
140
|
+
p = [(i32(fp.read(4)), i8(fp.read(1)), i32(fp.read(4))) for _ in range(nprops)]
|
|
141
|
+
|
|
142
|
+
if nprops & 3:
|
|
143
|
+
fp.seek(4 - (nprops & 3), io.SEEK_CUR) # pad
|
|
144
|
+
|
|
145
|
+
data = fp.read(i32(fp.read(4)))
|
|
146
|
+
|
|
147
|
+
for k, s, v in p:
|
|
148
|
+
property_value: bytes | int = sz(data, v) if s else v
|
|
149
|
+
properties[sz(data, k)] = property_value
|
|
150
|
+
|
|
151
|
+
return properties
|
|
152
|
+
|
|
153
|
+
def _load_metrics(self) -> list[tuple[int, int, int, int, int, int, int, int]]:
|
|
154
|
+
#
|
|
155
|
+
# font metrics
|
|
156
|
+
|
|
157
|
+
metrics: list[tuple[int, int, int, int, int, int, int, int]] = []
|
|
158
|
+
|
|
159
|
+
fp, format, i16, i32 = self._getformat(PCF_METRICS)
|
|
160
|
+
|
|
161
|
+
def append(
|
|
162
|
+
left: int,
|
|
163
|
+
right: int,
|
|
164
|
+
width: int,
|
|
165
|
+
ascent: int,
|
|
166
|
+
descent: int,
|
|
167
|
+
attributes: int = 0,
|
|
168
|
+
) -> None:
|
|
169
|
+
xsize = right - left
|
|
170
|
+
ysize = ascent + descent
|
|
171
|
+
Image._decompression_bomb_check((xsize, ysize))
|
|
172
|
+
metrics.append(
|
|
173
|
+
(xsize, ysize, left, right, width, ascent, descent, attributes)
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
if (format & 0xFF00) == 0x100:
|
|
177
|
+
# "compressed" metrics
|
|
178
|
+
for i in range(i16(fp.read(2))):
|
|
179
|
+
append(*(i8(fp.read(1)) - 128 for _ in range(5)))
|
|
180
|
+
|
|
181
|
+
else:
|
|
182
|
+
# "jumbo" metrics
|
|
183
|
+
for i in range(i32(fp.read(4))):
|
|
184
|
+
append(*(i16(fp.read(2)) for _ in range(6)))
|
|
185
|
+
|
|
186
|
+
return metrics
|
|
187
|
+
|
|
188
|
+
def _load_bitmaps(
|
|
189
|
+
self, metrics: list[tuple[int, int, int, int, int, int, int, int]]
|
|
190
|
+
) -> list[Image.Image]:
|
|
191
|
+
#
|
|
192
|
+
# bitmap data
|
|
193
|
+
|
|
194
|
+
fp, format, i16, i32 = self._getformat(PCF_BITMAPS)
|
|
195
|
+
|
|
196
|
+
nbitmaps = i32(fp.read(4))
|
|
197
|
+
|
|
198
|
+
if nbitmaps != len(metrics):
|
|
199
|
+
msg = "Wrong number of bitmaps"
|
|
200
|
+
raise OSError(msg)
|
|
201
|
+
|
|
202
|
+
offsets = [i32(fp.read(4)) for _ in range(nbitmaps)]
|
|
203
|
+
|
|
204
|
+
bitmap_sizes = [i32(fp.read(4)) for _ in range(4)]
|
|
205
|
+
|
|
206
|
+
# byteorder = format & 4 # non-zero => MSB
|
|
207
|
+
bitorder = format & 8 # non-zero => MSB
|
|
208
|
+
padindex = format & 3
|
|
209
|
+
|
|
210
|
+
bitmapsize = bitmap_sizes[padindex]
|
|
211
|
+
offsets.append(bitmapsize)
|
|
212
|
+
|
|
213
|
+
data = fp.read(bitmapsize)
|
|
214
|
+
|
|
215
|
+
pad = BYTES_PER_ROW[padindex]
|
|
216
|
+
mode = "1;R"
|
|
217
|
+
if bitorder:
|
|
218
|
+
mode = "1"
|
|
219
|
+
|
|
220
|
+
bitmaps = []
|
|
221
|
+
for i in range(nbitmaps):
|
|
222
|
+
xsize, ysize = metrics[i][:2]
|
|
223
|
+
b, e = offsets[i : i + 2]
|
|
224
|
+
bitmaps.append(
|
|
225
|
+
Image.frombytes("1", (xsize, ysize), data[b:e], "raw", mode, pad(xsize))
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
return bitmaps
|
|
229
|
+
|
|
230
|
+
def _load_encoding(self) -> list[int | None]:
|
|
231
|
+
fp, format, i16, i32 = self._getformat(PCF_BDF_ENCODINGS)
|
|
232
|
+
|
|
233
|
+
first_col, last_col = i16(fp.read(2)), i16(fp.read(2))
|
|
234
|
+
first_row, last_row = i16(fp.read(2)), i16(fp.read(2))
|
|
235
|
+
|
|
236
|
+
i16(fp.read(2)) # default
|
|
237
|
+
|
|
238
|
+
nencoding = (last_col - first_col + 1) * (last_row - first_row + 1)
|
|
239
|
+
|
|
240
|
+
# map character code to bitmap index
|
|
241
|
+
encoding: list[int | None] = [None] * min(256, nencoding)
|
|
242
|
+
|
|
243
|
+
encoding_offsets = [i16(fp.read(2)) for _ in range(nencoding)]
|
|
244
|
+
|
|
245
|
+
for i in range(first_col, len(encoding)):
|
|
246
|
+
try:
|
|
247
|
+
encoding_offset = encoding_offsets[
|
|
248
|
+
ord(bytearray([i]).decode(self.charset_encoding))
|
|
249
|
+
]
|
|
250
|
+
if encoding_offset != 0xFFFF:
|
|
251
|
+
encoding[i] = encoding_offset
|
|
252
|
+
except UnicodeDecodeError: # noqa: PERF203
|
|
253
|
+
# character is not supported in selected encoding
|
|
254
|
+
pass
|
|
255
|
+
|
|
256
|
+
return encoding
|