feat: add pack command, video TEX support, .mpkg support, and bugfixes#73
Open
addallno wants to merge 5 commits into
Open
feat: add pack command, video TEX support, .mpkg support, and bugfixes#73addallno wants to merge 5 commits into
addallno wants to merge 5 commits into
Conversation
The previous code wrote input.Length (character count) instead of Encoding.UTF8.GetBytes(input).Length (byte count). This caused path strings containing non-ASCII characters (e.g., Chinese) to be written with incorrect length prefix, corrupting the PKG header.
- Add net8.0 alongside net472 for cross-platform support - Conditional Microsoft.CSharp reference for net472 only
When source mipmap dimensions differ from header dimensions, resize instead of only cropping. Also handle the case where source is smaller than header dimensions.
- Info.cs: recognize .mpkg files when processing single file input - Info.cs: merge .pkg and .mpkg directory enumeration - Extract.cs: recognize .mpkg files in single file mode - Extract.cs: merge recursive and non-recursive .pkg/.mpkg enumeration
Pack command (repkg pack):
- Directory mode: pack directory to .pkg or .mpkg
- File mode: convert image/gif/video to .tex texture
- Auto-detect magic: .pkg -> PKGV0005, .mpkg -> PKGM0019
- Options: --format, --lz4, --no-gif, --video-width/height
ImageToTexConverter:
- Convert PNG, JPEG, GIF to TEX textures (RGBA8888/R8/RG88)
- Convert GIF animations to multi-frame TEX with frame info
- Convert MP4/WebM/MOV/AVI to video TEX (MP4 wrapped in TEX container)
V4 texture container support:
- TexImageContainerWriter: write V4 header (Format + isVideoMp4 flag)
- TexImageWriter: add WriteMipmapV4 with extra metadata fields
- For non-MP4 V4 containers, fall back to V3 mipmap format (matching
official Wallpaper Engine TEX structure)
- ITexImageWriter interface updated to pass FreeImageFormat
Program.cs: register PackOptions verb for CLI dispatch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a
packcommand for creating.pkg/.mpkgpackages and.textextures from images, GIFs, and video files. It also adds.mpkgextension support to existing commands (info,extract) and fixes a Unicode path bug in the PKG writer.Commits
1. fix: use UTF-8 byte count in WriteStringI32Size
WriteStringI32Sizeusedinput.Length(character count) instead of UTF-8bytes.Length. Non-ASCII filenames (e.g., Chinese) had incorrect length prefix, corrupting PKG headers.2. build: add net8.0 target framework
Dual-target
net472;net8.0for cross-platform compatibility. ConditionalMicrosoft.CSharpreference.3. fix: improve TexToImageConverter crop/resize logic
Handle case where mipmap dimensions are smaller than header dimensions by resizing.
4. fix: support .mpkg extension in info and extract commands
.mpkgfiles in single-file mode (was only.pkg).pkg/.mpkgdirectory enumeration into singleConcatcalls5. feat: add pack command and video TEX support
New
packcommand:repkg pack <dir>— pack directory to.pkg/.mpkgwith auto-magic detectionrepkg pack <file>— convert image (PNG/JPG/GIF) or video (MP4/WebM) to.tex--mpkgflag /.mpkgoutput extension → autoPKGM0019magic (Android).pkgoutput → autoPKGV0005magic (desktop)--format,--lz4,--no-gif,--video-width/height,-mmagic overrideNew ImageToTexConverter:
TEXS0003frame infoV4 container writer: