polyfile-weave 0.5.5__py3-none-any.whl
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.
Potentially problematic release.
This version of polyfile-weave might be problematic. Click here for more details.
- polyfile/__init__.py +15 -0
- polyfile/__main__.py +394 -0
- polyfile/arithmetic.py +27 -0
- polyfile/ast.py +114 -0
- polyfile/debugger.py +1039 -0
- polyfile/expressions.py +346 -0
- polyfile/fileutils.py +343 -0
- polyfile/html.py +135 -0
- polyfile/http/__init__.py +1 -0
- polyfile/http/defacto.py +37 -0
- polyfile/http/deprecated.py +51 -0
- polyfile/http/experimental.py +67 -0
- polyfile/http/http_11.py +548 -0
- polyfile/http/matcher.py +37 -0
- polyfile/http/structured_headers.py +48 -0
- polyfile/iterators.py +72 -0
- polyfile/jpeg.py +24 -0
- polyfile/kaitai/__init__.py +0 -0
- polyfile/kaitai/compiler.py +156 -0
- polyfile/kaitai/parser.py +312 -0
- polyfile/kaitai/parsers/__init__.py +0 -0
- polyfile/kaitai/parsers/aix_utmp.py +116 -0
- polyfile/kaitai/parsers/allegro_dat.py +367 -0
- polyfile/kaitai/parsers/andes_firmware.py +64 -0
- polyfile/kaitai/parsers/android_bootldr_asus.py +105 -0
- polyfile/kaitai/parsers/android_bootldr_huawei.py +181 -0
- polyfile/kaitai/parsers/android_bootldr_qcom.py +217 -0
- polyfile/kaitai/parsers/android_dto.py +138 -0
- polyfile/kaitai/parsers/android_img.py +319 -0
- polyfile/kaitai/parsers/android_nanoapp_header.py +83 -0
- polyfile/kaitai/parsers/android_opengl_shaders_cache.py +151 -0
- polyfile/kaitai/parsers/android_sparse.py +237 -0
- polyfile/kaitai/parsers/android_super.py +401 -0
- polyfile/kaitai/parsers/apm_partition_table.py +196 -0
- polyfile/kaitai/parsers/apple_single_double.py +180 -0
- polyfile/kaitai/parsers/asn1_der.py +235 -0
- polyfile/kaitai/parsers/au.py +138 -0
- polyfile/kaitai/parsers/avantes_roh60.py +112 -0
- polyfile/kaitai/parsers/avi.py +296 -0
- polyfile/kaitai/parsers/bcd.py +111 -0
- polyfile/kaitai/parsers/bitcoin_transaction.py +210 -0
- polyfile/kaitai/parsers/blender_blend.py +334 -0
- polyfile/kaitai/parsers/bmp.py +780 -0
- polyfile/kaitai/parsers/bson.py +411 -0
- polyfile/kaitai/parsers/btrfs_stream.py +318 -0
- polyfile/kaitai/parsers/bytes_with_io.py +27 -0
- polyfile/kaitai/parsers/chrome_pak.py +194 -0
- polyfile/kaitai/parsers/code_6502.py +456 -0
- polyfile/kaitai/parsers/compressed_resource.py +217 -0
- polyfile/kaitai/parsers/cpio_old_le.py +154 -0
- polyfile/kaitai/parsers/cramfs.py +344 -0
- polyfile/kaitai/parsers/creative_voice_file.py +342 -0
- polyfile/kaitai/parsers/dbf.py +274 -0
- polyfile/kaitai/parsers/dcmp_0.py +664 -0
- polyfile/kaitai/parsers/dcmp_1.py +422 -0
- polyfile/kaitai/parsers/dcmp_2.py +312 -0
- polyfile/kaitai/parsers/dcmp_variable_length_integer.py +66 -0
- polyfile/kaitai/parsers/dex.py +1086 -0
- polyfile/kaitai/parsers/dicom.py +4370 -0
- polyfile/kaitai/parsers/dime_message.py +201 -0
- polyfile/kaitai/parsers/dns_packet.py +569 -0
- polyfile/kaitai/parsers/doom_wad.py +654 -0
- polyfile/kaitai/parsers/dos_datetime.py +191 -0
- polyfile/kaitai/parsers/dos_mz.py +172 -0
- polyfile/kaitai/parsers/ds_store.py +513 -0
- polyfile/kaitai/parsers/dtb.py +310 -0
- polyfile/kaitai/parsers/dune_2_pak.py +126 -0
- polyfile/kaitai/parsers/edid.py +472 -0
- polyfile/kaitai/parsers/efivar_signature_list.py +331 -0
- polyfile/kaitai/parsers/elf.py +2482 -0
- polyfile/kaitai/parsers/ethernet_frame.py +114 -0
- polyfile/kaitai/parsers/exif.py +723 -0
- polyfile/kaitai/parsers/ext2.py +537 -0
- polyfile/kaitai/parsers/fallout2_dat.py +187 -0
- polyfile/kaitai/parsers/fallout_dat.py +156 -0
- polyfile/kaitai/parsers/fasttracker_xm_module.py +558 -0
- polyfile/kaitai/parsers/ftl_dat.py +90 -0
- polyfile/kaitai/parsers/genmidi_op2.py +161 -0
- polyfile/kaitai/parsers/gettext_mo.py +541 -0
- polyfile/kaitai/parsers/gif.py +492 -0
- polyfile/kaitai/parsers/gimp_brush.py +244 -0
- polyfile/kaitai/parsers/glibc_utmp.py +114 -0
- polyfile/kaitai/parsers/gltf_binary.py +132 -0
- polyfile/kaitai/parsers/google_protobuf.py +151 -0
- polyfile/kaitai/parsers/gpt_partition_table.py +175 -0
- polyfile/kaitai/parsers/gran_turismo_vol.py +140 -0
- polyfile/kaitai/parsers/grub2_font.py +337 -0
- polyfile/kaitai/parsers/gzip.py +232 -0
- polyfile/kaitai/parsers/hashcat_restore.py +60 -0
- polyfile/kaitai/parsers/hccap.py +111 -0
- polyfile/kaitai/parsers/hccapx.py +103 -0
- polyfile/kaitai/parsers/heaps_pak.py +177 -0
- polyfile/kaitai/parsers/heroes_of_might_and_magic_agg.py +116 -0
- polyfile/kaitai/parsers/heroes_of_might_and_magic_bmp.py +34 -0
- polyfile/kaitai/parsers/icmp_packet.py +136 -0
- polyfile/kaitai/parsers/ico.py +129 -0
- polyfile/kaitai/parsers/id3v1_1.py +220 -0
- polyfile/kaitai/parsers/id3v2_3.py +324 -0
- polyfile/kaitai/parsers/id3v2_4.py +423 -0
- polyfile/kaitai/parsers/ines.py +282 -0
- polyfile/kaitai/parsers/ipv4_packet.py +158 -0
- polyfile/kaitai/parsers/ipv6_packet.py +55 -0
- polyfile/kaitai/parsers/iso9660.py +544 -0
- polyfile/kaitai/parsers/java_class.py +1113 -0
- polyfile/kaitai/parsers/jpeg.py +361 -0
- polyfile/kaitai/parsers/luks.py +149 -0
- polyfile/kaitai/parsers/lzh.py +165 -0
- polyfile/kaitai/parsers/mac_os_resource_snd.py +493 -0
- polyfile/kaitai/parsers/mach_o.py +3033 -0
- polyfile/kaitai/parsers/mach_o_fat.py +92 -0
- polyfile/kaitai/parsers/magicavoxel_vox.py +391 -0
- polyfile/kaitai/parsers/manifest.json +1 -0
- polyfile/kaitai/parsers/mbr_partition_table.py +119 -0
- polyfile/kaitai/parsers/mcap.py +1015 -0
- polyfile/kaitai/parsers/microsoft_cfb.py +293 -0
- polyfile/kaitai/parsers/microsoft_network_monitor_v2.py +309 -0
- polyfile/kaitai/parsers/microsoft_pe.py +765 -0
- polyfile/kaitai/parsers/mifare_classic.py +706 -0
- polyfile/kaitai/parsers/minecraft_nbt.py +449 -0
- polyfile/kaitai/parsers/monomakh_sapr_chg.py +69 -0
- polyfile/kaitai/parsers/mozilla_mar.py +239 -0
- polyfile/kaitai/parsers/mp4.py +333 -0
- polyfile/kaitai/parsers/msgpack.py +467 -0
- polyfile/kaitai/parsers/nitf.py +1189 -0
- polyfile/kaitai/parsers/nt_mdt_pal.py +155 -0
- polyfile/kaitai/parsers/ogg.py +118 -0
- polyfile/kaitai/parsers/openpgp_message.py +993 -0
- polyfile/kaitai/parsers/packet_ppi.py +515 -0
- polyfile/kaitai/parsers/pcap.py +344 -0
- polyfile/kaitai/parsers/pcf_font.py +506 -0
- polyfile/kaitai/parsers/pcx.py +195 -0
- polyfile/kaitai/parsers/pcx_dcx.py +79 -0
- polyfile/kaitai/parsers/phar_without_stub.py +399 -0
- polyfile/kaitai/parsers/php_serialized_value.py +505 -0
- polyfile/kaitai/parsers/png.py +721 -0
- polyfile/kaitai/parsers/protocol_body.py +260 -0
- polyfile/kaitai/parsers/psx_tim.py +104 -0
- polyfile/kaitai/parsers/python_pickle.py +718 -0
- polyfile/kaitai/parsers/python_pyc_27.py +510 -0
- polyfile/kaitai/parsers/quake_mdl.py +441 -0
- polyfile/kaitai/parsers/quake_pak.py +112 -0
- polyfile/kaitai/parsers/quicktime_mov.py +634 -0
- polyfile/kaitai/parsers/rar.py +265 -0
- polyfile/kaitai/parsers/regf.py +569 -0
- polyfile/kaitai/parsers/renderware_binary_stream.py +877 -0
- polyfile/kaitai/parsers/resource_fork.py +611 -0
- polyfile/kaitai/parsers/respack.py +57 -0
- polyfile/kaitai/parsers/riff.py +409 -0
- polyfile/kaitai/parsers/rpm.py +964 -0
- polyfile/kaitai/parsers/rtcp_payload.py +579 -0
- polyfile/kaitai/parsers/rtp_packet.py +150 -0
- polyfile/kaitai/parsers/rtpdump.py +115 -0
- polyfile/kaitai/parsers/ruby_marshal.py +423 -0
- polyfile/kaitai/parsers/s3m.py +493 -0
- polyfile/kaitai/parsers/saints_row_2_vpp_pc.py +254 -0
- polyfile/kaitai/parsers/shapefile_index.py +174 -0
- polyfile/kaitai/parsers/shapefile_main.py +893 -0
- polyfile/kaitai/parsers/some_ip.py +209 -0
- polyfile/kaitai/parsers/some_ip_container.py +37 -0
- polyfile/kaitai/parsers/some_ip_sd.py +86 -0
- polyfile/kaitai/parsers/some_ip_sd_entries.py +160 -0
- polyfile/kaitai/parsers/some_ip_sd_options.py +374 -0
- polyfile/kaitai/parsers/specpr.py +404 -0
- polyfile/kaitai/parsers/sqlite3.py +472 -0
- polyfile/kaitai/parsers/ssh_public_key.py +252 -0
- polyfile/kaitai/parsers/standard_midi_file.py +390 -0
- polyfile/kaitai/parsers/stl.py +111 -0
- polyfile/kaitai/parsers/sudoers_ts.py +201 -0
- polyfile/kaitai/parsers/swf.py +406 -0
- polyfile/kaitai/parsers/systemd_journal.py +361 -0
- polyfile/kaitai/parsers/tcp_segment.py +57 -0
- polyfile/kaitai/parsers/tga.py +213 -0
- polyfile/kaitai/parsers/tls_client_hello.py +293 -0
- polyfile/kaitai/parsers/tr_dos_image.py +322 -0
- polyfile/kaitai/parsers/tsm.py +198 -0
- polyfile/kaitai/parsers/ttf.py +1847 -0
- polyfile/kaitai/parsers/udp_datagram.py +42 -0
- polyfile/kaitai/parsers/uefi_te.py +236 -0
- polyfile/kaitai/parsers/uimage.py +198 -0
- polyfile/kaitai/parsers/utf8_string.py +137 -0
- polyfile/kaitai/parsers/vfat.py +410 -0
- polyfile/kaitai/parsers/vlq_base128_be.py +104 -0
- polyfile/kaitai/parsers/vlq_base128_le.py +129 -0
- polyfile/kaitai/parsers/vmware_vmdk.py +167 -0
- polyfile/kaitai/parsers/vp8_ivf.py +112 -0
- polyfile/kaitai/parsers/warcraft_2_pud.py +423 -0
- polyfile/kaitai/parsers/wav.py +1014 -0
- polyfile/kaitai/parsers/websocket.py +167 -0
- polyfile/kaitai/parsers/windows_evt_log.py +304 -0
- polyfile/kaitai/parsers/windows_lnk_file.py +467 -0
- polyfile/kaitai/parsers/windows_minidump.py +575 -0
- polyfile/kaitai/parsers/windows_resource_file.py +243 -0
- polyfile/kaitai/parsers/windows_shell_items.py +190 -0
- polyfile/kaitai/parsers/windows_systemtime.py +52 -0
- polyfile/kaitai/parsers/wmf.py +502 -0
- polyfile/kaitai/parsers/xar.py +181 -0
- polyfile/kaitai/parsers/xwd.py +189 -0
- polyfile/kaitai/parsers/zip.py +685 -0
- polyfile/kaitai/parsers/zisofs.py +158 -0
- polyfile/kaitai/parsers/zx_spectrum_tap.py +184 -0
- polyfile/kaitaimatcher.py +113 -0
- polyfile/languagematcher.py +217 -0
- polyfile/logger.py +135 -0
- polyfile/magic.py +2983 -0
- polyfile/magic_defs/COPYING +29 -0
- polyfile/magic_defs/__init__.py +0 -0
- polyfile/magic_defs/acorn +102 -0
- polyfile/magic_defs/adi +13 -0
- polyfile/magic_defs/adventure +122 -0
- polyfile/magic_defs/aes +29 -0
- polyfile/magic_defs/algol68 +35 -0
- polyfile/magic_defs/allegro +9 -0
- polyfile/magic_defs/alliant +18 -0
- polyfile/magic_defs/alpha +32 -0
- polyfile/magic_defs/amanda +12 -0
- polyfile/magic_defs/amigaos +218 -0
- polyfile/magic_defs/android +259 -0
- polyfile/magic_defs/animation +1197 -0
- polyfile/magic_defs/aout +46 -0
- polyfile/magic_defs/apache +28 -0
- polyfile/magic_defs/apl +7 -0
- polyfile/magic_defs/apple +773 -0
- polyfile/magic_defs/application +7 -0
- polyfile/magic_defs/applix +13 -0
- polyfile/magic_defs/apt +52 -0
- polyfile/magic_defs/archive +2586 -0
- polyfile/magic_defs/aria +38 -0
- polyfile/magic_defs/arm +50 -0
- polyfile/magic_defs/asf +132 -0
- polyfile/magic_defs/assembler +18 -0
- polyfile/magic_defs/asterix +18 -0
- polyfile/magic_defs/att3b +41 -0
- polyfile/magic_defs/audio +1291 -0
- polyfile/magic_defs/avm +33 -0
- polyfile/magic_defs/basis +18 -0
- polyfile/magic_defs/beetle +7 -0
- polyfile/magic_defs/ber +65 -0
- polyfile/magic_defs/bflt +14 -0
- polyfile/magic_defs/bhl +10 -0
- polyfile/magic_defs/bioinformatics +178 -0
- polyfile/magic_defs/biosig +154 -0
- polyfile/magic_defs/blackberry +8 -0
- polyfile/magic_defs/blcr +25 -0
- polyfile/magic_defs/blender +50 -0
- polyfile/magic_defs/blit +24 -0
- polyfile/magic_defs/bm +10 -0
- polyfile/magic_defs/bout +11 -0
- polyfile/magic_defs/bsdi +33 -0
- polyfile/magic_defs/bsi +10 -0
- polyfile/magic_defs/btsnoop +13 -0
- polyfile/magic_defs/burp +7 -0
- polyfile/magic_defs/bytecode +41 -0
- polyfile/magic_defs/c-lang +110 -0
- polyfile/magic_defs/c64 +531 -0
- polyfile/magic_defs/cad +437 -0
- polyfile/magic_defs/cafebabe +107 -0
- polyfile/magic_defs/cbor +21 -0
- polyfile/magic_defs/ccf +14 -0
- polyfile/magic_defs/cddb +12 -0
- polyfile/magic_defs/chord +15 -0
- polyfile/magic_defs/cisco +12 -0
- polyfile/magic_defs/citrus +12 -0
- polyfile/magic_defs/clarion +27 -0
- polyfile/magic_defs/claris +48 -0
- polyfile/magic_defs/clipper +65 -0
- polyfile/magic_defs/clojure +30 -0
- polyfile/magic_defs/coff +98 -0
- polyfile/magic_defs/commands +201 -0
- polyfile/magic_defs/communications +22 -0
- polyfile/magic_defs/compress +461 -0
- polyfile/magic_defs/console +1213 -0
- polyfile/magic_defs/convex +69 -0
- polyfile/magic_defs/coverage +91 -0
- polyfile/magic_defs/cracklib +14 -0
- polyfile/magic_defs/crypto +31 -0
- polyfile/magic_defs/csv +8 -0
- polyfile/magic_defs/ctags +6 -0
- polyfile/magic_defs/ctf +23 -0
- polyfile/magic_defs/cubemap +8 -0
- polyfile/magic_defs/cups +56 -0
- polyfile/magic_defs/dact +11 -0
- polyfile/magic_defs/database +886 -0
- polyfile/magic_defs/dataone +47 -0
- polyfile/magic_defs/dbpf +15 -0
- polyfile/magic_defs/der +146 -0
- polyfile/magic_defs/diamond +12 -0
- polyfile/magic_defs/dif +33 -0
- polyfile/magic_defs/diff +41 -0
- polyfile/magic_defs/digital +59 -0
- polyfile/magic_defs/dolby +69 -0
- polyfile/magic_defs/dsf +25 -0
- polyfile/magic_defs/dump +96 -0
- polyfile/magic_defs/dwarfs +45 -0
- polyfile/magic_defs/dyadic +61 -0
- polyfile/magic_defs/ebml +8 -0
- polyfile/magic_defs/edid +11 -0
- polyfile/magic_defs/editors +43 -0
- polyfile/magic_defs/efi +15 -0
- polyfile/magic_defs/elf +379 -0
- polyfile/magic_defs/encore +22 -0
- polyfile/magic_defs/epoc +62 -0
- polyfile/magic_defs/erlang +21 -0
- polyfile/magic_defs/espressif +57 -0
- polyfile/magic_defs/esri +28 -0
- polyfile/magic_defs/etf +33 -0
- polyfile/magic_defs/fcs +9 -0
- polyfile/magic_defs/filesystems +2694 -0
- polyfile/magic_defs/finger +16 -0
- polyfile/magic_defs/firmware +133 -0
- polyfile/magic_defs/flash +62 -0
- polyfile/magic_defs/flif +36 -0
- polyfile/magic_defs/fonts +449 -0
- polyfile/magic_defs/forth +82 -0
- polyfile/magic_defs/fortran +9 -0
- polyfile/magic_defs/frame +62 -0
- polyfile/magic_defs/freebsd +164 -0
- polyfile/magic_defs/fsav +128 -0
- polyfile/magic_defs/fusecompress +12 -0
- polyfile/magic_defs/games +696 -0
- polyfile/magic_defs/gcc +17 -0
- polyfile/magic_defs/gconv +10 -0
- polyfile/magic_defs/gentoo +85 -0
- polyfile/magic_defs/geo +166 -0
- polyfile/magic_defs/geos +20 -0
- polyfile/magic_defs/gimp +77 -0
- polyfile/magic_defs/git +13 -0
- polyfile/magic_defs/glibc +21 -0
- polyfile/magic_defs/gnome +59 -0
- polyfile/magic_defs/gnu +173 -0
- polyfile/magic_defs/gnumeric +8 -0
- polyfile/magic_defs/gpt +240 -0
- polyfile/magic_defs/gpu +28 -0
- polyfile/magic_defs/grace +21 -0
- polyfile/magic_defs/graphviz +12 -0
- polyfile/magic_defs/gringotts +48 -0
- polyfile/magic_defs/guile +13 -0
- polyfile/magic_defs/hardware +12 -0
- polyfile/magic_defs/hitachi-sh +30 -0
- polyfile/magic_defs/hp +433 -0
- polyfile/magic_defs/human68k +26 -0
- polyfile/magic_defs/ibm370 +52 -0
- polyfile/magic_defs/ibm6000 +35 -0
- polyfile/magic_defs/icc +214 -0
- polyfile/magic_defs/iff +80 -0
- polyfile/magic_defs/images +4210 -0
- polyfile/magic_defs/inform +9 -0
- polyfile/magic_defs/intel +310 -0
- polyfile/magic_defs/interleaf +9 -0
- polyfile/magic_defs/island +10 -0
- polyfile/magic_defs/ispell +63 -0
- polyfile/magic_defs/isz +15 -0
- polyfile/magic_defs/java +52 -0
- polyfile/magic_defs/javascript +171 -0
- polyfile/magic_defs/jpeg +252 -0
- polyfile/magic_defs/json +8 -0
- polyfile/magic_defs/karma +9 -0
- polyfile/magic_defs/kde +11 -0
- polyfile/magic_defs/keepass +20 -0
- polyfile/magic_defs/kerberos +45 -0
- polyfile/magic_defs/kicad +85 -0
- polyfile/magic_defs/kml +34 -0
- polyfile/magic_defs/lammps +64 -0
- polyfile/magic_defs/lecter +6 -0
- polyfile/magic_defs/lex +12 -0
- polyfile/magic_defs/lif +50 -0
- polyfile/magic_defs/linux +557 -0
- polyfile/magic_defs/lisp +78 -0
- polyfile/magic_defs/llvm +22 -0
- polyfile/magic_defs/locoscript +12 -0
- polyfile/magic_defs/lua +31 -0
- polyfile/magic_defs/luks +126 -0
- polyfile/magic_defs/m4 +11 -0
- polyfile/magic_defs/mach +303 -0
- polyfile/magic_defs/macintosh +505 -0
- polyfile/magic_defs/macos +7 -0
- polyfile/magic_defs/magic +10 -0
- polyfile/magic_defs/magic.mgc +0 -0
- polyfile/magic_defs/mail.news +132 -0
- polyfile/magic_defs/make +21 -0
- polyfile/magic_defs/map +413 -0
- polyfile/magic_defs/maple +109 -0
- polyfile/magic_defs/marc21 +30 -0
- polyfile/magic_defs/mathcad +8 -0
- polyfile/magic_defs/mathematica +188 -0
- polyfile/magic_defs/matroska +17 -0
- polyfile/magic_defs/mcrypt +52 -0
- polyfile/magic_defs/measure +44 -0
- polyfile/magic_defs/mercurial +13 -0
- polyfile/magic_defs/metastore +8 -0
- polyfile/magic_defs/meteorological +53 -0
- polyfile/magic_defs/microfocus +21 -0
- polyfile/magic_defs/mime +9 -0
- polyfile/magic_defs/mips +120 -0
- polyfile/magic_defs/mirage +8 -0
- polyfile/magic_defs/misctools +140 -0
- polyfile/magic_defs/mkid +11 -0
- polyfile/magic_defs/mlssa +8 -0
- polyfile/magic_defs/mmdf +6 -0
- polyfile/magic_defs/modem +92 -0
- polyfile/magic_defs/modulefile +9 -0
- polyfile/magic_defs/motorola +71 -0
- polyfile/magic_defs/mozilla +37 -0
- polyfile/magic_defs/msdos +2304 -0
- polyfile/magic_defs/msooxml +68 -0
- polyfile/magic_defs/msvc +222 -0
- polyfile/magic_defs/msx +309 -0
- polyfile/magic_defs/mup +24 -0
- polyfile/magic_defs/music +17 -0
- polyfile/magic_defs/nasa +7 -0
- polyfile/magic_defs/natinst +24 -0
- polyfile/magic_defs/ncr +49 -0
- polyfile/magic_defs/neko +12 -0
- polyfile/magic_defs/netbsd +251 -0
- polyfile/magic_defs/netscape +26 -0
- polyfile/magic_defs/netware +11 -0
- polyfile/magic_defs/news +13 -0
- polyfile/magic_defs/nifty +202 -0
- polyfile/magic_defs/nim-lang +29 -0
- polyfile/magic_defs/nitpicker +14 -0
- polyfile/magic_defs/numpy +9 -0
- polyfile/magic_defs/oasis +12 -0
- polyfile/magic_defs/ocaml +14 -0
- polyfile/magic_defs/octave +6 -0
- polyfile/magic_defs/ole2compounddocs +760 -0
- polyfile/magic_defs/olf +98 -0
- polyfile/magic_defs/openfst +17 -0
- polyfile/magic_defs/opentimestamps +16 -0
- polyfile/magic_defs/oric +16 -0
- polyfile/magic_defs/os2 +186 -0
- polyfile/magic_defs/os400 +39 -0
- polyfile/magic_defs/os9 +80 -0
- polyfile/magic_defs/osf1 +10 -0
- polyfile/magic_defs/palm +156 -0
- polyfile/magic_defs/parix +13 -0
- polyfile/magic_defs/parrot +22 -0
- polyfile/magic_defs/pascal +39 -0
- polyfile/magic_defs/pbf +11 -0
- polyfile/magic_defs/pbm +8 -0
- polyfile/magic_defs/pc88 +24 -0
- polyfile/magic_defs/pc98 +77 -0
- polyfile/magic_defs/pci_ids +116 -0
- polyfile/magic_defs/pcjr +8 -0
- polyfile/magic_defs/pdf +51 -0
- polyfile/magic_defs/pdp +42 -0
- polyfile/magic_defs/perl +100 -0
- polyfile/magic_defs/pgf +52 -0
- polyfile/magic_defs/pgp +581 -0
- polyfile/magic_defs/pgp-binary-keys +388 -0
- polyfile/magic_defs/pkgadd +7 -0
- polyfile/magic_defs/plan9 +25 -0
- polyfile/magic_defs/playdate +57 -0
- polyfile/magic_defs/plus5 +18 -0
- polyfile/magic_defs/pmem +46 -0
- polyfile/magic_defs/polyfile_zip +5 -0
- polyfile/magic_defs/polyml +23 -0
- polyfile/magic_defs/printer +269 -0
- polyfile/magic_defs/project +10 -0
- polyfile/magic_defs/psdbms +14 -0
- polyfile/magic_defs/psl +14 -0
- polyfile/magic_defs/pulsar +13 -0
- polyfile/magic_defs/puzzle +17 -0
- polyfile/magic_defs/pwsafe +14 -0
- polyfile/magic_defs/pyramid +12 -0
- polyfile/magic_defs/python +305 -0
- polyfile/magic_defs/qt +30 -0
- polyfile/magic_defs/revision +66 -0
- polyfile/magic_defs/riff +840 -0
- polyfile/magic_defs/rinex +44 -0
- polyfile/magic_defs/ringdove +45 -0
- polyfile/magic_defs/rpi +52 -0
- polyfile/magic_defs/rpm +45 -0
- polyfile/magic_defs/rpmsg +7 -0
- polyfile/magic_defs/rst +11 -0
- polyfile/magic_defs/rtf +94 -0
- polyfile/magic_defs/ruby +55 -0
- polyfile/magic_defs/rust +21 -0
- polyfile/magic_defs/sc +7 -0
- polyfile/magic_defs/sccs +24 -0
- polyfile/magic_defs/scientific +144 -0
- polyfile/magic_defs/securitycerts +6 -0
- polyfile/magic_defs/selinux +24 -0
- polyfile/magic_defs/sendmail +37 -0
- polyfile/magic_defs/sequent +42 -0
- polyfile/magic_defs/sereal +35 -0
- polyfile/magic_defs/sgi +144 -0
- polyfile/magic_defs/sgml +161 -0
- polyfile/magic_defs/sharc +23 -0
- polyfile/magic_defs/sinclair +40 -0
- polyfile/magic_defs/sisu +18 -0
- polyfile/magic_defs/sketch +6 -0
- polyfile/magic_defs/smalltalk +25 -0
- polyfile/magic_defs/smile +34 -0
- polyfile/magic_defs/sniffer +482 -0
- polyfile/magic_defs/softquad +40 -0
- polyfile/magic_defs/sosi +40 -0
- polyfile/magic_defs/spec +21 -0
- polyfile/magic_defs/spectrum +184 -0
- polyfile/magic_defs/sql +288 -0
- polyfile/magic_defs/ssh +39 -0
- polyfile/magic_defs/ssl +20 -0
- polyfile/magic_defs/statistics +45 -0
- polyfile/magic_defs/subtitle +38 -0
- polyfile/magic_defs/sun +141 -0
- polyfile/magic_defs/svf +5 -0
- polyfile/magic_defs/sylk +36 -0
- polyfile/magic_defs/symbos +42 -0
- polyfile/magic_defs/sysex +429 -0
- polyfile/magic_defs/tcl +29 -0
- polyfile/magic_defs/teapot +6 -0
- polyfile/magic_defs/terminfo +63 -0
- polyfile/magic_defs/tex +141 -0
- polyfile/magic_defs/tgif +7 -0
- polyfile/magic_defs/ti-8x +239 -0
- polyfile/magic_defs/timezone +42 -0
- polyfile/magic_defs/tplink +95 -0
- polyfile/magic_defs/troff +38 -0
- polyfile/magic_defs/tuxedo +8 -0
- polyfile/magic_defs/typeset +8 -0
- polyfile/magic_defs/uf2 +72 -0
- polyfile/magic_defs/unicode +15 -0
- polyfile/magic_defs/unisig +12 -0
- polyfile/magic_defs/unknown +34 -0
- polyfile/magic_defs/usd +21 -0
- polyfile/magic_defs/uterus +16 -0
- polyfile/magic_defs/uuencode +28 -0
- polyfile/magic_defs/vacuum-cleaner +54 -0
- polyfile/magic_defs/varied.out +46 -0
- polyfile/magic_defs/varied.script +21 -0
- polyfile/magic_defs/vax +32 -0
- polyfile/magic_defs/vicar +17 -0
- polyfile/magic_defs/virtual +307 -0
- polyfile/magic_defs/virtutech +12 -0
- polyfile/magic_defs/visx +32 -0
- polyfile/magic_defs/vms +30 -0
- polyfile/magic_defs/vmware +6 -0
- polyfile/magic_defs/vorbis +155 -0
- polyfile/magic_defs/vxl +14 -0
- polyfile/magic_defs/warc +16 -0
- polyfile/magic_defs/weak +16 -0
- polyfile/magic_defs/web +18 -0
- polyfile/magic_defs/webassembly +17 -0
- polyfile/magic_defs/windows +1811 -0
- polyfile/magic_defs/wireless +7 -0
- polyfile/magic_defs/wordprocessors +630 -0
- polyfile/magic_defs/wsdl +23 -0
- polyfile/magic_defs/x68000 +25 -0
- polyfile/magic_defs/xdelta +13 -0
- polyfile/magic_defs/xenix +106 -0
- polyfile/magic_defs/xilinx +58 -0
- polyfile/magic_defs/xo65 +37 -0
- polyfile/magic_defs/xwindows +43 -0
- polyfile/magic_defs/yara +17 -0
- polyfile/magic_defs/zfs +96 -0
- polyfile/magic_defs/zilog +12 -0
- polyfile/magic_defs/zip +126 -0
- polyfile/magic_defs/zyxel +17 -0
- polyfile/nes.py +144 -0
- polyfile/nitf.py +15 -0
- polyfile/pdf.py +1264 -0
- polyfile/pickles.py +45 -0
- polyfile/polyfile.py +409 -0
- polyfile/profiling.py +115 -0
- polyfile/repl.py +624 -0
- polyfile/search.py +310 -0
- polyfile/serialization.py +323 -0
- polyfile/structmatcher.py +46 -0
- polyfile/structs.py +281 -0
- polyfile/templates/download.js +162 -0
- polyfile/templates/hexdump.css +268 -0
- polyfile/templates/hexdump.js +756 -0
- polyfile/templates/jquery-3.4.1.min.js +2 -0
- polyfile/templates/template.html +119 -0
- polyfile/wildcards.py +62 -0
- polyfile/zipmatcher.py +183 -0
- polyfile_weave-0.5.5.dist-info/METADATA +173 -0
- polyfile_weave-0.5.5.dist-info/RECORD +585 -0
- polyfile_weave-0.5.5.dist-info/WHEEL +5 -0
- polyfile_weave-0.5.5.dist-info/entry_points.txt +2 -0
- polyfile_weave-0.5.5.dist-info/licenses/LICENSE +202 -0
- polyfile_weave-0.5.5.dist-info/top_level.txt +2 -0
- polymerge/__init__.py +1 -0
- polymerge/__main__.py +296 -0
- polymerge/cfg.py +127 -0
- polymerge/polymerge.py +227 -0
- polymerge/polytracker.py +190 -0
|
@@ -0,0 +1,780 @@
|
|
|
1
|
+
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
|
|
2
|
+
|
|
3
|
+
from pkg_resources import parse_version
|
|
4
|
+
import kaitaistruct
|
|
5
|
+
from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
|
|
6
|
+
from enum import Enum
|
|
7
|
+
import collections
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
if parse_version(kaitaistruct.__version__) < parse_version('0.9'):
|
|
11
|
+
raise Exception("Incompatible Kaitai Struct Python API: 0.9 or later is required, but you have %s" % (kaitaistruct.__version__))
|
|
12
|
+
|
|
13
|
+
class Bmp(KaitaiStruct):
|
|
14
|
+
"""The **BMP file format**, also known as **bitmap image file** or **device independent
|
|
15
|
+
bitmap (DIB) file format** or simply a **bitmap**, is a raster graphics image file
|
|
16
|
+
format used to store bitmap digital images, independently of the display
|
|
17
|
+
device (such as a graphics adapter), especially on Microsoft Windows
|
|
18
|
+
and OS/2 operating systems.
|
|
19
|
+
|
|
20
|
+
## Samples
|
|
21
|
+
|
|
22
|
+
Great collection of various BMP sample files:
|
|
23
|
+
[**BMP Suite Image List**](
|
|
24
|
+
http://entropymine.com/jason/bmpsuite/bmpsuite/html/bmpsuite.html
|
|
25
|
+
) (by Jason Summers)
|
|
26
|
+
|
|
27
|
+
If only there was such a comprehensive sample suite for every file format! It's like
|
|
28
|
+
a dream for every developer of any binary file format parser. It contains a lot of
|
|
29
|
+
different types and variations of BMP files, even the tricky ones, where it's not clear
|
|
30
|
+
from the specification how to deal with them (marked there as "**q**uestionable").
|
|
31
|
+
|
|
32
|
+
If you make a program which will be able to read all the "**g**ood" and "**q**uestionable"
|
|
33
|
+
BMP files and won't crash on the "**b**ad" ones, it will definitely have one of the most
|
|
34
|
+
extensive support of BMP files in the universe!
|
|
35
|
+
|
|
36
|
+
## BITMAPV2INFOHEADER and BITMAPV3INFOHEADER
|
|
37
|
+
|
|
38
|
+
A beneficial discussion on Adobe forum (archived):
|
|
39
|
+
[**Invalid BMP Format with Alpha channel**](
|
|
40
|
+
https://web.archive.org/web/20150127132443/https://forums.adobe.com/message/3272950
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
In 2010, someone noticed that Photoshop generated BMP with an odd type of header. There wasn't
|
|
44
|
+
any documentation available for this header at the time (and still isn't).
|
|
45
|
+
However, Chris Cox (former Adobe employee) claimed that they hadn't invented any type
|
|
46
|
+
of proprietary header and everything they were writing was taken directly
|
|
47
|
+
from the Microsoft documentation.
|
|
48
|
+
|
|
49
|
+
It showed up that the unknown header was called BITMAPV3INFOHEADER.
|
|
50
|
+
Although Microsoft has apparently requested and verified the use of the header,
|
|
51
|
+
the documentation on MSDN has probably got lost and they have probably
|
|
52
|
+
forgotten about this type of header.
|
|
53
|
+
|
|
54
|
+
This is the only source I could find about these structures, so we could't rely
|
|
55
|
+
on it so much, but I think supporting them as a read-only format won't harm anything.
|
|
56
|
+
Due to the fact that it isn't documented anywhere else, most applications don't support it.
|
|
57
|
+
|
|
58
|
+
All Windows headers at once (including mentioned BITMAPV2INFOHEADER and BITMAPV3INFOHEADER):
|
|
59
|
+
|
|
60
|
+

|
|
63
|
+
|
|
64
|
+
## Specs
|
|
65
|
+
* [Bitmap Storage (Windows Dev Center)](
|
|
66
|
+
https://learn.microsoft.com/en-us/windows/win32/gdi/bitmap-storage
|
|
67
|
+
)
|
|
68
|
+
* BITMAPFILEHEADER
|
|
69
|
+
* BITMAPINFOHEADER
|
|
70
|
+
* BITMAPV4HEADER
|
|
71
|
+
* BITMAPV5HEADER
|
|
72
|
+
* [OS/2 Bitmap File Format](
|
|
73
|
+
https://www.fileformat.info/format/os2bmp/egff.htm
|
|
74
|
+
)
|
|
75
|
+
* BITMAPFILEHEADER (OS2BMPFILEHEADER)
|
|
76
|
+
* BITMAPCOREHEADER (OS21XBITMAPHEADER)
|
|
77
|
+
* OS22XBITMAPHEADER
|
|
78
|
+
* [Microsoft Windows Bitmap](
|
|
79
|
+
http://netghost.narod.ru/gff/graphics/summary/micbmp.htm
|
|
80
|
+
)
|
|
81
|
+
* BITMAPFILEHEADER (WINBMPFILEHEADER)
|
|
82
|
+
* BITMAPCOREHEADER (WIN2XBITMAPHEADER)
|
|
83
|
+
* BITMAPINFOHEADER (WINNTBITMAPHEADER)
|
|
84
|
+
* BITMAPV4HEADER (WIN4XBITMAPHEADER)
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
class Intent(Enum):
|
|
88
|
+
business = 1
|
|
89
|
+
graphics = 2
|
|
90
|
+
images = 4
|
|
91
|
+
abs_colorimetric = 8
|
|
92
|
+
|
|
93
|
+
class ColorSpace(Enum):
|
|
94
|
+
calibrated_rgb = 0
|
|
95
|
+
profile_linked = 1279872587
|
|
96
|
+
profile_embedded = 1296188740
|
|
97
|
+
windows = 1466527264
|
|
98
|
+
s_rgb = 1934772034
|
|
99
|
+
|
|
100
|
+
class Os2Rendering(Enum):
|
|
101
|
+
no_halftoning = 0
|
|
102
|
+
error_diffusion = 1
|
|
103
|
+
panda = 2
|
|
104
|
+
super_circle = 3
|
|
105
|
+
|
|
106
|
+
class HeaderType(Enum):
|
|
107
|
+
bitmap_core_header = 12
|
|
108
|
+
bitmap_info_header = 40
|
|
109
|
+
bitmap_v2_info_header = 52
|
|
110
|
+
bitmap_v3_info_header = 56
|
|
111
|
+
os2_2x_bitmap_header = 64
|
|
112
|
+
bitmap_v4_header = 108
|
|
113
|
+
bitmap_v5_header = 124
|
|
114
|
+
|
|
115
|
+
class Compressions(Enum):
|
|
116
|
+
rgb = 0
|
|
117
|
+
rle8 = 1
|
|
118
|
+
rle4 = 2
|
|
119
|
+
bitfields = 3
|
|
120
|
+
jpeg = 4
|
|
121
|
+
png = 5
|
|
122
|
+
alpha_bitfields = 6
|
|
123
|
+
|
|
124
|
+
class Os2Compressions(Enum):
|
|
125
|
+
rgb = 0
|
|
126
|
+
rle8 = 1
|
|
127
|
+
rle4 = 2
|
|
128
|
+
huffman_1d = 3
|
|
129
|
+
rle24 = 4
|
|
130
|
+
SEQ_FIELDS = ["file_hdr", "dib_info", "bitmap"]
|
|
131
|
+
def __init__(self, _io, _parent=None, _root=None):
|
|
132
|
+
self._io = _io
|
|
133
|
+
self._parent = _parent
|
|
134
|
+
self._root = _root if _root else self
|
|
135
|
+
self._debug = collections.defaultdict(dict)
|
|
136
|
+
|
|
137
|
+
def _read(self):
|
|
138
|
+
self._debug['file_hdr']['start'] = self._io.pos()
|
|
139
|
+
self.file_hdr = Bmp.FileHeader(self._io, self, self._root)
|
|
140
|
+
self.file_hdr._read()
|
|
141
|
+
self._debug['file_hdr']['end'] = self._io.pos()
|
|
142
|
+
self._debug['dib_info']['start'] = self._io.pos()
|
|
143
|
+
self._raw_dib_info = self._io.read_bytes((self.file_hdr.ofs_bitmap - 14))
|
|
144
|
+
_io__raw_dib_info = KaitaiStream(BytesIO(self._raw_dib_info))
|
|
145
|
+
self.dib_info = Bmp.BitmapInfo(_io__raw_dib_info, self, self._root)
|
|
146
|
+
self.dib_info._read()
|
|
147
|
+
self._debug['dib_info']['end'] = self._io.pos()
|
|
148
|
+
self._debug['bitmap']['start'] = self._io.pos()
|
|
149
|
+
self._raw_bitmap = self._io.read_bytes_full()
|
|
150
|
+
_io__raw_bitmap = KaitaiStream(BytesIO(self._raw_bitmap))
|
|
151
|
+
self.bitmap = Bmp.Bitmap(_io__raw_bitmap, self, self._root)
|
|
152
|
+
self.bitmap._read()
|
|
153
|
+
self._debug['bitmap']['end'] = self._io.pos()
|
|
154
|
+
|
|
155
|
+
class CieXyz(KaitaiStruct):
|
|
156
|
+
"""
|
|
157
|
+
.. seealso::
|
|
158
|
+
Source - https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-ciexyz
|
|
159
|
+
"""
|
|
160
|
+
SEQ_FIELDS = ["x", "y", "z"]
|
|
161
|
+
def __init__(self, _io, _parent=None, _root=None):
|
|
162
|
+
self._io = _io
|
|
163
|
+
self._parent = _parent
|
|
164
|
+
self._root = _root if _root else self
|
|
165
|
+
self._debug = collections.defaultdict(dict)
|
|
166
|
+
|
|
167
|
+
def _read(self):
|
|
168
|
+
self._debug['x']['start'] = self._io.pos()
|
|
169
|
+
self.x = Bmp.FixedPoint2Dot30(self._io, self, self._root)
|
|
170
|
+
self.x._read()
|
|
171
|
+
self._debug['x']['end'] = self._io.pos()
|
|
172
|
+
self._debug['y']['start'] = self._io.pos()
|
|
173
|
+
self.y = Bmp.FixedPoint2Dot30(self._io, self, self._root)
|
|
174
|
+
self.y._read()
|
|
175
|
+
self._debug['y']['end'] = self._io.pos()
|
|
176
|
+
self._debug['z']['start'] = self._io.pos()
|
|
177
|
+
self.z = Bmp.FixedPoint2Dot30(self._io, self, self._root)
|
|
178
|
+
self.z._read()
|
|
179
|
+
self._debug['z']['end'] = self._io.pos()
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class RgbRecord(KaitaiStruct):
|
|
183
|
+
SEQ_FIELDS = ["blue", "green", "red", "reserved"]
|
|
184
|
+
def __init__(self, has_reserved_field, _io, _parent=None, _root=None):
|
|
185
|
+
self._io = _io
|
|
186
|
+
self._parent = _parent
|
|
187
|
+
self._root = _root if _root else self
|
|
188
|
+
self.has_reserved_field = has_reserved_field
|
|
189
|
+
self._debug = collections.defaultdict(dict)
|
|
190
|
+
|
|
191
|
+
def _read(self):
|
|
192
|
+
self._debug['blue']['start'] = self._io.pos()
|
|
193
|
+
self.blue = self._io.read_u1()
|
|
194
|
+
self._debug['blue']['end'] = self._io.pos()
|
|
195
|
+
self._debug['green']['start'] = self._io.pos()
|
|
196
|
+
self.green = self._io.read_u1()
|
|
197
|
+
self._debug['green']['end'] = self._io.pos()
|
|
198
|
+
self._debug['red']['start'] = self._io.pos()
|
|
199
|
+
self.red = self._io.read_u1()
|
|
200
|
+
self._debug['red']['end'] = self._io.pos()
|
|
201
|
+
if self.has_reserved_field:
|
|
202
|
+
self._debug['reserved']['start'] = self._io.pos()
|
|
203
|
+
self.reserved = self._io.read_u1()
|
|
204
|
+
self._debug['reserved']['end'] = self._io.pos()
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class BitmapV5Extension(KaitaiStruct):
|
|
209
|
+
"""
|
|
210
|
+
.. seealso::
|
|
211
|
+
Source - https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapv5header
|
|
212
|
+
"""
|
|
213
|
+
SEQ_FIELDS = ["intent", "ofs_profile", "len_profile", "reserved"]
|
|
214
|
+
def __init__(self, _io, _parent=None, _root=None):
|
|
215
|
+
self._io = _io
|
|
216
|
+
self._parent = _parent
|
|
217
|
+
self._root = _root if _root else self
|
|
218
|
+
self._debug = collections.defaultdict(dict)
|
|
219
|
+
|
|
220
|
+
def _read(self):
|
|
221
|
+
self._debug['intent']['start'] = self._io.pos()
|
|
222
|
+
self.intent = KaitaiStream.resolve_enum(Bmp.Intent, self._io.read_u4le())
|
|
223
|
+
self._debug['intent']['end'] = self._io.pos()
|
|
224
|
+
self._debug['ofs_profile']['start'] = self._io.pos()
|
|
225
|
+
self.ofs_profile = self._io.read_u4le()
|
|
226
|
+
self._debug['ofs_profile']['end'] = self._io.pos()
|
|
227
|
+
self._debug['len_profile']['start'] = self._io.pos()
|
|
228
|
+
self.len_profile = self._io.read_u4le()
|
|
229
|
+
self._debug['len_profile']['end'] = self._io.pos()
|
|
230
|
+
self._debug['reserved']['start'] = self._io.pos()
|
|
231
|
+
self.reserved = self._io.read_u4le()
|
|
232
|
+
self._debug['reserved']['end'] = self._io.pos()
|
|
233
|
+
|
|
234
|
+
@property
|
|
235
|
+
def has_profile(self):
|
|
236
|
+
if hasattr(self, '_m_has_profile'):
|
|
237
|
+
return self._m_has_profile if hasattr(self, '_m_has_profile') else None
|
|
238
|
+
|
|
239
|
+
self._m_has_profile = ((self._parent.bitmap_v4_ext.color_space_type == Bmp.ColorSpace.profile_linked) or (self._parent.bitmap_v4_ext.color_space_type == Bmp.ColorSpace.profile_embedded))
|
|
240
|
+
return self._m_has_profile if hasattr(self, '_m_has_profile') else None
|
|
241
|
+
|
|
242
|
+
@property
|
|
243
|
+
def profile_data(self):
|
|
244
|
+
"""
|
|
245
|
+
.. seealso::
|
|
246
|
+
"If the profile is embedded, profile data is the actual profile, and if it is linked, the profile data is the null-terminated file name of the profile. This cannot be a Unicode string. It must be composed exclusively of characters from the Windows character set (code page 1252)." - https://learn.microsoft.com/en-us/windows/win32/wcs/using-structures-in-wcs-1-0
|
|
247
|
+
"""
|
|
248
|
+
if hasattr(self, '_m_profile_data'):
|
|
249
|
+
return self._m_profile_data if hasattr(self, '_m_profile_data') else None
|
|
250
|
+
|
|
251
|
+
if self.has_profile:
|
|
252
|
+
io = self._root._io
|
|
253
|
+
_pos = io.pos()
|
|
254
|
+
io.seek((14 + self.ofs_profile))
|
|
255
|
+
self._debug['_m_profile_data']['start'] = io.pos()
|
|
256
|
+
_on = self._parent.bitmap_v4_ext.color_space_type == Bmp.ColorSpace.profile_linked
|
|
257
|
+
if _on == True:
|
|
258
|
+
self._m_profile_data = (KaitaiStream.bytes_terminate(io.read_bytes(self.len_profile), 0, False)).decode(u"windows-1252")
|
|
259
|
+
else:
|
|
260
|
+
self._m_profile_data = io.read_bytes(self.len_profile)
|
|
261
|
+
self._debug['_m_profile_data']['end'] = io.pos()
|
|
262
|
+
io.seek(_pos)
|
|
263
|
+
|
|
264
|
+
return self._m_profile_data if hasattr(self, '_m_profile_data') else None
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
class ColorMask(KaitaiStruct):
|
|
268
|
+
SEQ_FIELDS = ["red_mask", "green_mask", "blue_mask", "alpha_mask"]
|
|
269
|
+
def __init__(self, has_alpha_mask, _io, _parent=None, _root=None):
|
|
270
|
+
self._io = _io
|
|
271
|
+
self._parent = _parent
|
|
272
|
+
self._root = _root if _root else self
|
|
273
|
+
self.has_alpha_mask = has_alpha_mask
|
|
274
|
+
self._debug = collections.defaultdict(dict)
|
|
275
|
+
|
|
276
|
+
def _read(self):
|
|
277
|
+
self._debug['red_mask']['start'] = self._io.pos()
|
|
278
|
+
self.red_mask = self._io.read_u4le()
|
|
279
|
+
self._debug['red_mask']['end'] = self._io.pos()
|
|
280
|
+
self._debug['green_mask']['start'] = self._io.pos()
|
|
281
|
+
self.green_mask = self._io.read_u4le()
|
|
282
|
+
self._debug['green_mask']['end'] = self._io.pos()
|
|
283
|
+
self._debug['blue_mask']['start'] = self._io.pos()
|
|
284
|
+
self.blue_mask = self._io.read_u4le()
|
|
285
|
+
self._debug['blue_mask']['end'] = self._io.pos()
|
|
286
|
+
if self.has_alpha_mask:
|
|
287
|
+
self._debug['alpha_mask']['start'] = self._io.pos()
|
|
288
|
+
self.alpha_mask = self._io.read_u4le()
|
|
289
|
+
self._debug['alpha_mask']['end'] = self._io.pos()
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
class BitmapV4Extension(KaitaiStruct):
|
|
294
|
+
"""
|
|
295
|
+
.. seealso::
|
|
296
|
+
Source - https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapv4header
|
|
297
|
+
"""
|
|
298
|
+
SEQ_FIELDS = ["color_space_type", "endpoint_red", "endpoint_green", "endpoint_blue", "gamma_red", "gamma_blue", "gamma_green"]
|
|
299
|
+
def __init__(self, _io, _parent=None, _root=None):
|
|
300
|
+
self._io = _io
|
|
301
|
+
self._parent = _parent
|
|
302
|
+
self._root = _root if _root else self
|
|
303
|
+
self._debug = collections.defaultdict(dict)
|
|
304
|
+
|
|
305
|
+
def _read(self):
|
|
306
|
+
self._debug['color_space_type']['start'] = self._io.pos()
|
|
307
|
+
self.color_space_type = KaitaiStream.resolve_enum(Bmp.ColorSpace, self._io.read_u4le())
|
|
308
|
+
self._debug['color_space_type']['end'] = self._io.pos()
|
|
309
|
+
self._debug['endpoint_red']['start'] = self._io.pos()
|
|
310
|
+
self.endpoint_red = Bmp.CieXyz(self._io, self, self._root)
|
|
311
|
+
self.endpoint_red._read()
|
|
312
|
+
self._debug['endpoint_red']['end'] = self._io.pos()
|
|
313
|
+
self._debug['endpoint_green']['start'] = self._io.pos()
|
|
314
|
+
self.endpoint_green = Bmp.CieXyz(self._io, self, self._root)
|
|
315
|
+
self.endpoint_green._read()
|
|
316
|
+
self._debug['endpoint_green']['end'] = self._io.pos()
|
|
317
|
+
self._debug['endpoint_blue']['start'] = self._io.pos()
|
|
318
|
+
self.endpoint_blue = Bmp.CieXyz(self._io, self, self._root)
|
|
319
|
+
self.endpoint_blue._read()
|
|
320
|
+
self._debug['endpoint_blue']['end'] = self._io.pos()
|
|
321
|
+
self._debug['gamma_red']['start'] = self._io.pos()
|
|
322
|
+
self.gamma_red = Bmp.FixedPoint16Dot16(self._io, self, self._root)
|
|
323
|
+
self.gamma_red._read()
|
|
324
|
+
self._debug['gamma_red']['end'] = self._io.pos()
|
|
325
|
+
self._debug['gamma_blue']['start'] = self._io.pos()
|
|
326
|
+
self.gamma_blue = Bmp.FixedPoint16Dot16(self._io, self, self._root)
|
|
327
|
+
self.gamma_blue._read()
|
|
328
|
+
self._debug['gamma_blue']['end'] = self._io.pos()
|
|
329
|
+
self._debug['gamma_green']['start'] = self._io.pos()
|
|
330
|
+
self.gamma_green = Bmp.FixedPoint16Dot16(self._io, self, self._root)
|
|
331
|
+
self.gamma_green._read()
|
|
332
|
+
self._debug['gamma_green']['end'] = self._io.pos()
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
class BitmapInfoExtension(KaitaiStruct):
|
|
336
|
+
"""
|
|
337
|
+
.. seealso::
|
|
338
|
+
Source - https://learn.microsoft.com/en-us/previous-versions/dd183376(v=vs.85)
|
|
339
|
+
"""
|
|
340
|
+
SEQ_FIELDS = ["compression", "os2_compression", "len_image", "x_resolution", "y_resolution", "num_colors_used", "num_colors_important"]
|
|
341
|
+
def __init__(self, _io, _parent=None, _root=None):
|
|
342
|
+
self._io = _io
|
|
343
|
+
self._parent = _parent
|
|
344
|
+
self._root = _root if _root else self
|
|
345
|
+
self._debug = collections.defaultdict(dict)
|
|
346
|
+
|
|
347
|
+
def _read(self):
|
|
348
|
+
if not (self._parent.extends_os2_2x_bitmap):
|
|
349
|
+
self._debug['compression']['start'] = self._io.pos()
|
|
350
|
+
self.compression = KaitaiStream.resolve_enum(Bmp.Compressions, self._io.read_u4le())
|
|
351
|
+
self._debug['compression']['end'] = self._io.pos()
|
|
352
|
+
|
|
353
|
+
if self._parent.extends_os2_2x_bitmap:
|
|
354
|
+
self._debug['os2_compression']['start'] = self._io.pos()
|
|
355
|
+
self.os2_compression = KaitaiStream.resolve_enum(Bmp.Os2Compressions, self._io.read_u4le())
|
|
356
|
+
self._debug['os2_compression']['end'] = self._io.pos()
|
|
357
|
+
|
|
358
|
+
self._debug['len_image']['start'] = self._io.pos()
|
|
359
|
+
self.len_image = self._io.read_u4le()
|
|
360
|
+
self._debug['len_image']['end'] = self._io.pos()
|
|
361
|
+
self._debug['x_resolution']['start'] = self._io.pos()
|
|
362
|
+
self.x_resolution = self._io.read_u4le()
|
|
363
|
+
self._debug['x_resolution']['end'] = self._io.pos()
|
|
364
|
+
self._debug['y_resolution']['start'] = self._io.pos()
|
|
365
|
+
self.y_resolution = self._io.read_u4le()
|
|
366
|
+
self._debug['y_resolution']['end'] = self._io.pos()
|
|
367
|
+
self._debug['num_colors_used']['start'] = self._io.pos()
|
|
368
|
+
self.num_colors_used = self._io.read_u4le()
|
|
369
|
+
self._debug['num_colors_used']['end'] = self._io.pos()
|
|
370
|
+
self._debug['num_colors_important']['start'] = self._io.pos()
|
|
371
|
+
self.num_colors_important = self._io.read_u4le()
|
|
372
|
+
self._debug['num_colors_important']['end'] = self._io.pos()
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
class FixedPoint2Dot30(KaitaiStruct):
|
|
376
|
+
SEQ_FIELDS = ["raw"]
|
|
377
|
+
def __init__(self, _io, _parent=None, _root=None):
|
|
378
|
+
self._io = _io
|
|
379
|
+
self._parent = _parent
|
|
380
|
+
self._root = _root if _root else self
|
|
381
|
+
self._debug = collections.defaultdict(dict)
|
|
382
|
+
|
|
383
|
+
def _read(self):
|
|
384
|
+
self._debug['raw']['start'] = self._io.pos()
|
|
385
|
+
self.raw = self._io.read_u4le()
|
|
386
|
+
self._debug['raw']['end'] = self._io.pos()
|
|
387
|
+
|
|
388
|
+
@property
|
|
389
|
+
def value(self):
|
|
390
|
+
if hasattr(self, '_m_value'):
|
|
391
|
+
return self._m_value if hasattr(self, '_m_value') else None
|
|
392
|
+
|
|
393
|
+
self._m_value = ((self.raw + 0.0) / (1 << 30))
|
|
394
|
+
return self._m_value if hasattr(self, '_m_value') else None
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
class Bitmap(KaitaiStruct):
|
|
398
|
+
"""Replace with an opaque type if you care about the pixels. You can look at
|
|
399
|
+
an example of a JavaScript implementation:
|
|
400
|
+
<https://github.com/generalmimon/bmptool/blob/master/src/Bitmap.js>
|
|
401
|
+
|
|
402
|
+
There is a proposal for adding bitmap data type to Kaitai Struct:
|
|
403
|
+
<https://github.com/kaitai-io/kaitai_struct/issues/188>
|
|
404
|
+
"""
|
|
405
|
+
SEQ_FIELDS = []
|
|
406
|
+
def __init__(self, _io, _parent=None, _root=None):
|
|
407
|
+
self._io = _io
|
|
408
|
+
self._parent = _parent
|
|
409
|
+
self._root = _root if _root else self
|
|
410
|
+
self._debug = collections.defaultdict(dict)
|
|
411
|
+
|
|
412
|
+
def _read(self):
|
|
413
|
+
pass
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
class BitmapHeader(KaitaiStruct):
|
|
417
|
+
"""
|
|
418
|
+
.. seealso::
|
|
419
|
+
Source - https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapcoreheader
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
.. seealso::
|
|
423
|
+
Source - https://www.fileformat.info/format/os2bmp/egff.htm#OS2BMP-DMYID.3.1
|
|
424
|
+
"""
|
|
425
|
+
SEQ_FIELDS = ["image_width", "image_height_raw", "num_planes", "bits_per_pixel", "bitmap_info_ext", "color_mask", "os2_2x_bitmap_ext", "bitmap_v4_ext", "bitmap_v5_ext"]
|
|
426
|
+
def __init__(self, len_header, _io, _parent=None, _root=None):
|
|
427
|
+
self._io = _io
|
|
428
|
+
self._parent = _parent
|
|
429
|
+
self._root = _root if _root else self
|
|
430
|
+
self.len_header = len_header
|
|
431
|
+
self._debug = collections.defaultdict(dict)
|
|
432
|
+
|
|
433
|
+
def _read(self):
|
|
434
|
+
self._debug['image_width']['start'] = self._io.pos()
|
|
435
|
+
_on = self.is_core_header
|
|
436
|
+
if _on == True:
|
|
437
|
+
self.image_width = self._io.read_u2le()
|
|
438
|
+
elif _on == False:
|
|
439
|
+
self.image_width = self._io.read_u4le()
|
|
440
|
+
self._debug['image_width']['end'] = self._io.pos()
|
|
441
|
+
self._debug['image_height_raw']['start'] = self._io.pos()
|
|
442
|
+
_on = self.is_core_header
|
|
443
|
+
if _on == True:
|
|
444
|
+
self.image_height_raw = self._io.read_s2le()
|
|
445
|
+
elif _on == False:
|
|
446
|
+
self.image_height_raw = self._io.read_s4le()
|
|
447
|
+
self._debug['image_height_raw']['end'] = self._io.pos()
|
|
448
|
+
self._debug['num_planes']['start'] = self._io.pos()
|
|
449
|
+
self.num_planes = self._io.read_u2le()
|
|
450
|
+
self._debug['num_planes']['end'] = self._io.pos()
|
|
451
|
+
self._debug['bits_per_pixel']['start'] = self._io.pos()
|
|
452
|
+
self.bits_per_pixel = self._io.read_u2le()
|
|
453
|
+
self._debug['bits_per_pixel']['end'] = self._io.pos()
|
|
454
|
+
if self.extends_bitmap_info:
|
|
455
|
+
self._debug['bitmap_info_ext']['start'] = self._io.pos()
|
|
456
|
+
self.bitmap_info_ext = Bmp.BitmapInfoExtension(self._io, self, self._root)
|
|
457
|
+
self.bitmap_info_ext._read()
|
|
458
|
+
self._debug['bitmap_info_ext']['end'] = self._io.pos()
|
|
459
|
+
|
|
460
|
+
if self.is_color_mask_here:
|
|
461
|
+
self._debug['color_mask']['start'] = self._io.pos()
|
|
462
|
+
self.color_mask = Bmp.ColorMask(self.len_header != Bmp.HeaderType.bitmap_v2_info_header.value, self._io, self, self._root)
|
|
463
|
+
self.color_mask._read()
|
|
464
|
+
self._debug['color_mask']['end'] = self._io.pos()
|
|
465
|
+
|
|
466
|
+
if self.extends_os2_2x_bitmap:
|
|
467
|
+
self._debug['os2_2x_bitmap_ext']['start'] = self._io.pos()
|
|
468
|
+
self.os2_2x_bitmap_ext = Bmp.Os22xBitmapExtension(self._io, self, self._root)
|
|
469
|
+
self.os2_2x_bitmap_ext._read()
|
|
470
|
+
self._debug['os2_2x_bitmap_ext']['end'] = self._io.pos()
|
|
471
|
+
|
|
472
|
+
if self.extends_bitmap_v4:
|
|
473
|
+
self._debug['bitmap_v4_ext']['start'] = self._io.pos()
|
|
474
|
+
self.bitmap_v4_ext = Bmp.BitmapV4Extension(self._io, self, self._root)
|
|
475
|
+
self.bitmap_v4_ext._read()
|
|
476
|
+
self._debug['bitmap_v4_ext']['end'] = self._io.pos()
|
|
477
|
+
|
|
478
|
+
if self.extends_bitmap_v5:
|
|
479
|
+
self._debug['bitmap_v5_ext']['start'] = self._io.pos()
|
|
480
|
+
self.bitmap_v5_ext = Bmp.BitmapV5Extension(self._io, self, self._root)
|
|
481
|
+
self.bitmap_v5_ext._read()
|
|
482
|
+
self._debug['bitmap_v5_ext']['end'] = self._io.pos()
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
@property
|
|
486
|
+
def extends_bitmap_v4(self):
|
|
487
|
+
if hasattr(self, '_m_extends_bitmap_v4'):
|
|
488
|
+
return self._m_extends_bitmap_v4 if hasattr(self, '_m_extends_bitmap_v4') else None
|
|
489
|
+
|
|
490
|
+
self._m_extends_bitmap_v4 = self.len_header >= Bmp.HeaderType.bitmap_v4_header.value
|
|
491
|
+
return self._m_extends_bitmap_v4 if hasattr(self, '_m_extends_bitmap_v4') else None
|
|
492
|
+
|
|
493
|
+
@property
|
|
494
|
+
def extends_os2_2x_bitmap(self):
|
|
495
|
+
if hasattr(self, '_m_extends_os2_2x_bitmap'):
|
|
496
|
+
return self._m_extends_os2_2x_bitmap if hasattr(self, '_m_extends_os2_2x_bitmap') else None
|
|
497
|
+
|
|
498
|
+
self._m_extends_os2_2x_bitmap = self.len_header == Bmp.HeaderType.os2_2x_bitmap_header.value
|
|
499
|
+
return self._m_extends_os2_2x_bitmap if hasattr(self, '_m_extends_os2_2x_bitmap') else None
|
|
500
|
+
|
|
501
|
+
@property
|
|
502
|
+
def uses_fixed_palette(self):
|
|
503
|
+
if hasattr(self, '_m_uses_fixed_palette'):
|
|
504
|
+
return self._m_uses_fixed_palette if hasattr(self, '_m_uses_fixed_palette') else None
|
|
505
|
+
|
|
506
|
+
self._m_uses_fixed_palette = ((not ( ((self.bits_per_pixel == 16) or (self.bits_per_pixel == 24) or (self.bits_per_pixel == 32)) )) and (not ( ((self.extends_bitmap_info) and (not (self.extends_os2_2x_bitmap)) and ( ((self.bitmap_info_ext.compression == Bmp.Compressions.jpeg) or (self.bitmap_info_ext.compression == Bmp.Compressions.png)) )) )))
|
|
507
|
+
return self._m_uses_fixed_palette if hasattr(self, '_m_uses_fixed_palette') else None
|
|
508
|
+
|
|
509
|
+
@property
|
|
510
|
+
def extends_bitmap_info(self):
|
|
511
|
+
if hasattr(self, '_m_extends_bitmap_info'):
|
|
512
|
+
return self._m_extends_bitmap_info if hasattr(self, '_m_extends_bitmap_info') else None
|
|
513
|
+
|
|
514
|
+
self._m_extends_bitmap_info = self.len_header >= Bmp.HeaderType.bitmap_info_header.value
|
|
515
|
+
return self._m_extends_bitmap_info if hasattr(self, '_m_extends_bitmap_info') else None
|
|
516
|
+
|
|
517
|
+
@property
|
|
518
|
+
def image_height(self):
|
|
519
|
+
if hasattr(self, '_m_image_height'):
|
|
520
|
+
return self._m_image_height if hasattr(self, '_m_image_height') else None
|
|
521
|
+
|
|
522
|
+
self._m_image_height = (-(self.image_height_raw) if self.image_height_raw < 0 else self.image_height_raw)
|
|
523
|
+
return self._m_image_height if hasattr(self, '_m_image_height') else None
|
|
524
|
+
|
|
525
|
+
@property
|
|
526
|
+
def is_core_header(self):
|
|
527
|
+
if hasattr(self, '_m_is_core_header'):
|
|
528
|
+
return self._m_is_core_header if hasattr(self, '_m_is_core_header') else None
|
|
529
|
+
|
|
530
|
+
self._m_is_core_header = self.len_header == Bmp.HeaderType.bitmap_core_header.value
|
|
531
|
+
return self._m_is_core_header if hasattr(self, '_m_is_core_header') else None
|
|
532
|
+
|
|
533
|
+
@property
|
|
534
|
+
def extends_bitmap_v5(self):
|
|
535
|
+
if hasattr(self, '_m_extends_bitmap_v5'):
|
|
536
|
+
return self._m_extends_bitmap_v5 if hasattr(self, '_m_extends_bitmap_v5') else None
|
|
537
|
+
|
|
538
|
+
self._m_extends_bitmap_v5 = self.len_header >= Bmp.HeaderType.bitmap_v5_header.value
|
|
539
|
+
return self._m_extends_bitmap_v5 if hasattr(self, '_m_extends_bitmap_v5') else None
|
|
540
|
+
|
|
541
|
+
@property
|
|
542
|
+
def is_color_mask_here(self):
|
|
543
|
+
if hasattr(self, '_m_is_color_mask_here'):
|
|
544
|
+
return self._m_is_color_mask_here if hasattr(self, '_m_is_color_mask_here') else None
|
|
545
|
+
|
|
546
|
+
self._m_is_color_mask_here = ((self.len_header == Bmp.HeaderType.bitmap_v2_info_header.value) or (self.len_header == Bmp.HeaderType.bitmap_v3_info_header.value) or (self.extends_bitmap_v4))
|
|
547
|
+
return self._m_is_color_mask_here if hasattr(self, '_m_is_color_mask_here') else None
|
|
548
|
+
|
|
549
|
+
@property
|
|
550
|
+
def bottom_up(self):
|
|
551
|
+
if hasattr(self, '_m_bottom_up'):
|
|
552
|
+
return self._m_bottom_up if hasattr(self, '_m_bottom_up') else None
|
|
553
|
+
|
|
554
|
+
self._m_bottom_up = self.image_height_raw > 0
|
|
555
|
+
return self._m_bottom_up if hasattr(self, '_m_bottom_up') else None
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
class Os22xBitmapExtension(KaitaiStruct):
|
|
559
|
+
"""
|
|
560
|
+
.. seealso::
|
|
561
|
+
Source - https://www.fileformat.info/format/os2bmp/egff.htm#OS2BMP-DMYID.3.2
|
|
562
|
+
"""
|
|
563
|
+
SEQ_FIELDS = ["units", "reserved", "recording", "rendering", "size1", "size2", "color_encoding", "identifier"]
|
|
564
|
+
def __init__(self, _io, _parent=None, _root=None):
|
|
565
|
+
self._io = _io
|
|
566
|
+
self._parent = _parent
|
|
567
|
+
self._root = _root if _root else self
|
|
568
|
+
self._debug = collections.defaultdict(dict)
|
|
569
|
+
|
|
570
|
+
def _read(self):
|
|
571
|
+
self._debug['units']['start'] = self._io.pos()
|
|
572
|
+
self.units = self._io.read_u2le()
|
|
573
|
+
self._debug['units']['end'] = self._io.pos()
|
|
574
|
+
self._debug['reserved']['start'] = self._io.pos()
|
|
575
|
+
self.reserved = self._io.read_u2le()
|
|
576
|
+
self._debug['reserved']['end'] = self._io.pos()
|
|
577
|
+
self._debug['recording']['start'] = self._io.pos()
|
|
578
|
+
self.recording = self._io.read_u2le()
|
|
579
|
+
self._debug['recording']['end'] = self._io.pos()
|
|
580
|
+
self._debug['rendering']['start'] = self._io.pos()
|
|
581
|
+
self.rendering = KaitaiStream.resolve_enum(Bmp.Os2Rendering, self._io.read_u2le())
|
|
582
|
+
self._debug['rendering']['end'] = self._io.pos()
|
|
583
|
+
self._debug['size1']['start'] = self._io.pos()
|
|
584
|
+
self.size1 = self._io.read_u4le()
|
|
585
|
+
self._debug['size1']['end'] = self._io.pos()
|
|
586
|
+
self._debug['size2']['start'] = self._io.pos()
|
|
587
|
+
self.size2 = self._io.read_u4le()
|
|
588
|
+
self._debug['size2']['end'] = self._io.pos()
|
|
589
|
+
self._debug['color_encoding']['start'] = self._io.pos()
|
|
590
|
+
self.color_encoding = self._io.read_u4le()
|
|
591
|
+
self._debug['color_encoding']['end'] = self._io.pos()
|
|
592
|
+
self._debug['identifier']['start'] = self._io.pos()
|
|
593
|
+
self.identifier = self._io.read_u4le()
|
|
594
|
+
self._debug['identifier']['end'] = self._io.pos()
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
class FixedPoint16Dot16(KaitaiStruct):
|
|
598
|
+
SEQ_FIELDS = ["raw"]
|
|
599
|
+
def __init__(self, _io, _parent=None, _root=None):
|
|
600
|
+
self._io = _io
|
|
601
|
+
self._parent = _parent
|
|
602
|
+
self._root = _root if _root else self
|
|
603
|
+
self._debug = collections.defaultdict(dict)
|
|
604
|
+
|
|
605
|
+
def _read(self):
|
|
606
|
+
self._debug['raw']['start'] = self._io.pos()
|
|
607
|
+
self.raw = self._io.read_u4le()
|
|
608
|
+
self._debug['raw']['end'] = self._io.pos()
|
|
609
|
+
|
|
610
|
+
@property
|
|
611
|
+
def value(self):
|
|
612
|
+
if hasattr(self, '_m_value'):
|
|
613
|
+
return self._m_value if hasattr(self, '_m_value') else None
|
|
614
|
+
|
|
615
|
+
self._m_value = ((self.raw + 0.0) / (1 << 16))
|
|
616
|
+
return self._m_value if hasattr(self, '_m_value') else None
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
class ColorTable(KaitaiStruct):
|
|
620
|
+
SEQ_FIELDS = ["colors"]
|
|
621
|
+
def __init__(self, has_reserved_field, num_colors, _io, _parent=None, _root=None):
|
|
622
|
+
self._io = _io
|
|
623
|
+
self._parent = _parent
|
|
624
|
+
self._root = _root if _root else self
|
|
625
|
+
self.has_reserved_field = has_reserved_field
|
|
626
|
+
self.num_colors = num_colors
|
|
627
|
+
self._debug = collections.defaultdict(dict)
|
|
628
|
+
|
|
629
|
+
def _read(self):
|
|
630
|
+
self._debug['colors']['start'] = self._io.pos()
|
|
631
|
+
self.colors = [None] * ((self.num_colors if ((self.num_colors > 0) and (self.num_colors < self.num_colors_present)) else self.num_colors_present))
|
|
632
|
+
for i in range((self.num_colors if ((self.num_colors > 0) and (self.num_colors < self.num_colors_present)) else self.num_colors_present)):
|
|
633
|
+
if not 'arr' in self._debug['colors']:
|
|
634
|
+
self._debug['colors']['arr'] = []
|
|
635
|
+
self._debug['colors']['arr'].append({'start': self._io.pos()})
|
|
636
|
+
_t_colors = Bmp.RgbRecord(self.has_reserved_field, self._io, self, self._root)
|
|
637
|
+
_t_colors._read()
|
|
638
|
+
self.colors[i] = _t_colors
|
|
639
|
+
self._debug['colors']['arr'][i]['end'] = self._io.pos()
|
|
640
|
+
|
|
641
|
+
self._debug['colors']['end'] = self._io.pos()
|
|
642
|
+
|
|
643
|
+
@property
|
|
644
|
+
def num_colors_present(self):
|
|
645
|
+
if hasattr(self, '_m_num_colors_present'):
|
|
646
|
+
return self._m_num_colors_present if hasattr(self, '_m_num_colors_present') else None
|
|
647
|
+
|
|
648
|
+
self._m_num_colors_present = self._io.size() // (4 if self.has_reserved_field else 3)
|
|
649
|
+
return self._m_num_colors_present if hasattr(self, '_m_num_colors_present') else None
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
class FileHeader(KaitaiStruct):
|
|
653
|
+
"""
|
|
654
|
+
.. seealso::
|
|
655
|
+
Source - https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapfileheader
|
|
656
|
+
"""
|
|
657
|
+
SEQ_FIELDS = ["file_type", "len_file", "reserved1", "reserved2", "ofs_bitmap"]
|
|
658
|
+
def __init__(self, _io, _parent=None, _root=None):
|
|
659
|
+
self._io = _io
|
|
660
|
+
self._parent = _parent
|
|
661
|
+
self._root = _root if _root else self
|
|
662
|
+
self._debug = collections.defaultdict(dict)
|
|
663
|
+
|
|
664
|
+
def _read(self):
|
|
665
|
+
self._debug['file_type']['start'] = self._io.pos()
|
|
666
|
+
self.file_type = self._io.read_bytes(2)
|
|
667
|
+
self._debug['file_type']['end'] = self._io.pos()
|
|
668
|
+
if not self.file_type == b"\x42\x4D":
|
|
669
|
+
raise kaitaistruct.ValidationNotEqualError(b"\x42\x4D", self.file_type, self._io, u"/types/file_header/seq/0")
|
|
670
|
+
self._debug['len_file']['start'] = self._io.pos()
|
|
671
|
+
self.len_file = self._io.read_u4le()
|
|
672
|
+
self._debug['len_file']['end'] = self._io.pos()
|
|
673
|
+
self._debug['reserved1']['start'] = self._io.pos()
|
|
674
|
+
self.reserved1 = self._io.read_u2le()
|
|
675
|
+
self._debug['reserved1']['end'] = self._io.pos()
|
|
676
|
+
self._debug['reserved2']['start'] = self._io.pos()
|
|
677
|
+
self.reserved2 = self._io.read_u2le()
|
|
678
|
+
self._debug['reserved2']['end'] = self._io.pos()
|
|
679
|
+
self._debug['ofs_bitmap']['start'] = self._io.pos()
|
|
680
|
+
self.ofs_bitmap = self._io.read_s4le()
|
|
681
|
+
self._debug['ofs_bitmap']['end'] = self._io.pos()
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
class BitmapInfo(KaitaiStruct):
|
|
685
|
+
"""
|
|
686
|
+
.. seealso::
|
|
687
|
+
Source - https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfo
|
|
688
|
+
"""
|
|
689
|
+
SEQ_FIELDS = ["len_header", "header", "color_mask", "color_table"]
|
|
690
|
+
def __init__(self, _io, _parent=None, _root=None):
|
|
691
|
+
self._io = _io
|
|
692
|
+
self._parent = _parent
|
|
693
|
+
self._root = _root if _root else self
|
|
694
|
+
self._debug = collections.defaultdict(dict)
|
|
695
|
+
|
|
696
|
+
def _read(self):
|
|
697
|
+
self._debug['len_header']['start'] = self._io.pos()
|
|
698
|
+
self.len_header = self._io.read_u4le()
|
|
699
|
+
self._debug['len_header']['end'] = self._io.pos()
|
|
700
|
+
self._debug['header']['start'] = self._io.pos()
|
|
701
|
+
self._raw_header = self._io.read_bytes((self.len_header - 4))
|
|
702
|
+
_io__raw_header = KaitaiStream(BytesIO(self._raw_header))
|
|
703
|
+
self.header = Bmp.BitmapHeader(self.len_header, _io__raw_header, self, self._root)
|
|
704
|
+
self.header._read()
|
|
705
|
+
self._debug['header']['end'] = self._io.pos()
|
|
706
|
+
if self.is_color_mask_here:
|
|
707
|
+
self._debug['color_mask']['start'] = self._io.pos()
|
|
708
|
+
self.color_mask = Bmp.ColorMask(self.header.bitmap_info_ext.compression == Bmp.Compressions.alpha_bitfields, self._io, self, self._root)
|
|
709
|
+
self.color_mask._read()
|
|
710
|
+
self._debug['color_mask']['end'] = self._io.pos()
|
|
711
|
+
|
|
712
|
+
if not (self._io.is_eof()):
|
|
713
|
+
self._debug['color_table']['start'] = self._io.pos()
|
|
714
|
+
self._raw_color_table = self._io.read_bytes_full()
|
|
715
|
+
_io__raw_color_table = KaitaiStream(BytesIO(self._raw_color_table))
|
|
716
|
+
self.color_table = Bmp.ColorTable(not (self.header.is_core_header), (self.header.bitmap_info_ext.num_colors_used if self.header.extends_bitmap_info else 0), _io__raw_color_table, self, self._root)
|
|
717
|
+
self.color_table._read()
|
|
718
|
+
self._debug['color_table']['end'] = self._io.pos()
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
@property
|
|
722
|
+
def is_color_mask_given(self):
|
|
723
|
+
if hasattr(self, '_m_is_color_mask_given'):
|
|
724
|
+
return self._m_is_color_mask_given if hasattr(self, '_m_is_color_mask_given') else None
|
|
725
|
+
|
|
726
|
+
self._m_is_color_mask_given = ((self.header.extends_bitmap_info) and ( ((self.header.bitmap_info_ext.compression == Bmp.Compressions.bitfields) or (self.header.bitmap_info_ext.compression == Bmp.Compressions.alpha_bitfields)) ) and ( ((self.is_color_mask_here) or (self.header.is_color_mask_here)) ))
|
|
727
|
+
return self._m_is_color_mask_given if hasattr(self, '_m_is_color_mask_given') else None
|
|
728
|
+
|
|
729
|
+
@property
|
|
730
|
+
def color_mask_given(self):
|
|
731
|
+
if hasattr(self, '_m_color_mask_given'):
|
|
732
|
+
return self._m_color_mask_given if hasattr(self, '_m_color_mask_given') else None
|
|
733
|
+
|
|
734
|
+
if self.is_color_mask_given:
|
|
735
|
+
self._m_color_mask_given = (self.color_mask if self.is_color_mask_here else self.header.color_mask)
|
|
736
|
+
|
|
737
|
+
return self._m_color_mask_given if hasattr(self, '_m_color_mask_given') else None
|
|
738
|
+
|
|
739
|
+
@property
|
|
740
|
+
def color_mask_blue(self):
|
|
741
|
+
if hasattr(self, '_m_color_mask_blue'):
|
|
742
|
+
return self._m_color_mask_blue if hasattr(self, '_m_color_mask_blue') else None
|
|
743
|
+
|
|
744
|
+
self._m_color_mask_blue = (self.color_mask_given.blue_mask if self.is_color_mask_given else (31 if self.header.bits_per_pixel == 16 else (255 if ((self.header.bits_per_pixel == 24) or (self.header.bits_per_pixel == 32)) else 0)))
|
|
745
|
+
return self._m_color_mask_blue if hasattr(self, '_m_color_mask_blue') else None
|
|
746
|
+
|
|
747
|
+
@property
|
|
748
|
+
def color_mask_alpha(self):
|
|
749
|
+
if hasattr(self, '_m_color_mask_alpha'):
|
|
750
|
+
return self._m_color_mask_alpha if hasattr(self, '_m_color_mask_alpha') else None
|
|
751
|
+
|
|
752
|
+
self._m_color_mask_alpha = (self.color_mask_given.alpha_mask if ((self.is_color_mask_given) and (self.color_mask_given.has_alpha_mask)) else 0)
|
|
753
|
+
return self._m_color_mask_alpha if hasattr(self, '_m_color_mask_alpha') else None
|
|
754
|
+
|
|
755
|
+
@property
|
|
756
|
+
def color_mask_green(self):
|
|
757
|
+
if hasattr(self, '_m_color_mask_green'):
|
|
758
|
+
return self._m_color_mask_green if hasattr(self, '_m_color_mask_green') else None
|
|
759
|
+
|
|
760
|
+
self._m_color_mask_green = (self.color_mask_given.green_mask if self.is_color_mask_given else (992 if self.header.bits_per_pixel == 16 else (65280 if ((self.header.bits_per_pixel == 24) or (self.header.bits_per_pixel == 32)) else 0)))
|
|
761
|
+
return self._m_color_mask_green if hasattr(self, '_m_color_mask_green') else None
|
|
762
|
+
|
|
763
|
+
@property
|
|
764
|
+
def is_color_mask_here(self):
|
|
765
|
+
if hasattr(self, '_m_is_color_mask_here'):
|
|
766
|
+
return self._m_is_color_mask_here if hasattr(self, '_m_is_color_mask_here') else None
|
|
767
|
+
|
|
768
|
+
self._m_is_color_mask_here = ((not (self._io.is_eof())) and (self.header.len_header == Bmp.HeaderType.bitmap_info_header.value) and ( ((self.header.bitmap_info_ext.compression == Bmp.Compressions.bitfields) or (self.header.bitmap_info_ext.compression == Bmp.Compressions.alpha_bitfields)) ))
|
|
769
|
+
return self._m_is_color_mask_here if hasattr(self, '_m_is_color_mask_here') else None
|
|
770
|
+
|
|
771
|
+
@property
|
|
772
|
+
def color_mask_red(self):
|
|
773
|
+
if hasattr(self, '_m_color_mask_red'):
|
|
774
|
+
return self._m_color_mask_red if hasattr(self, '_m_color_mask_red') else None
|
|
775
|
+
|
|
776
|
+
self._m_color_mask_red = (self.color_mask_given.red_mask if self.is_color_mask_given else (31744 if self.header.bits_per_pixel == 16 else (16711680 if ((self.header.bits_per_pixel == 24) or (self.header.bits_per_pixel == 32)) else 0)))
|
|
777
|
+
return self._m_color_mask_red if hasattr(self, '_m_color_mask_red') else None
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|