mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-07-08 01:31:53 +08:00
fix bug
This commit is contained in:
@@ -85,7 +85,7 @@ yaneurao-itufuru = ["yaneurao"]
|
|||||||
# basic feature
|
# basic feature
|
||||||
image = ["png"]
|
image = ["png"]
|
||||||
image-jpg = ["mozjpeg"]
|
image-jpg = ["mozjpeg"]
|
||||||
image-jxl = ["jpegxl-sys"]
|
image-jxl = ["image", "jpegxl-sys"]
|
||||||
image-webp = ["webp"]
|
image-webp = ["webp"]
|
||||||
lossless-audio = ["utils-pcm"]
|
lossless-audio = ["utils-pcm"]
|
||||||
audio-flac = ["libflac-sys", "utils-pcm"]
|
audio-flac = ["libflac-sys", "utils-pcm"]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
//! JPEG XL image support
|
//! JPEG XL image support
|
||||||
|
use super::img::*;
|
||||||
use crate::types::*;
|
use crate::types::*;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use jpegxl_sys::common::types::*;
|
use jpegxl_sys::common::types::*;
|
||||||
@@ -144,7 +145,7 @@ pub fn decode_jxl<R: Read>(mut r: R) -> Result<ImageData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Encode image data to JXL format
|
/// Encode image data to JXL format
|
||||||
pub fn encode_jxl(img: ImageData, _config: &ExtraConfig) -> Result<Vec<u8>> {
|
pub fn encode_jxl(mut img: ImageData, _config: &ExtraConfig) -> Result<Vec<u8>> {
|
||||||
let encoder = unsafe { JxlEncoderCreate(std::ptr::null()) };
|
let encoder = unsafe { JxlEncoderCreate(std::ptr::null()) };
|
||||||
if encoder.is_null() {
|
if encoder.is_null() {
|
||||||
return Err(anyhow::anyhow!("Failed to create JXL encoder"));
|
return Err(anyhow::anyhow!("Failed to create JXL encoder"));
|
||||||
@@ -194,6 +195,15 @@ pub fn encode_jxl(img: ImageData, _config: &ExtraConfig) -> Result<Vec<u8>> {
|
|||||||
endianness: JxlEndianness::Little,
|
endianness: JxlEndianness::Little,
|
||||||
align: 0,
|
align: 0,
|
||||||
};
|
};
|
||||||
|
match img.color_type {
|
||||||
|
ImageColorType::Bgr => {
|
||||||
|
convert_bgr_to_rgb(&mut img)?;
|
||||||
|
}
|
||||||
|
ImageColorType::Bgra => {
|
||||||
|
convert_bgra_to_rgba(&mut img)?;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
};
|
||||||
check_encoder_status(unsafe {
|
check_encoder_status(unsafe {
|
||||||
JxlEncoderAddImageFrame(
|
JxlEncoderAddImageFrame(
|
||||||
options,
|
options,
|
||||||
|
|||||||
Reference in New Issue
Block a user