Use libjpeg-turbo for improved jpg compatibility and speed

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
This commit is contained in:
Daniel Kinsman
2025-03-17 15:10:36 +11:00
committed by Rémi Verschelde
parent cc948984ad
commit a0cc41b5ed
131 changed files with 50882 additions and 5276 deletions

View File

@@ -133,6 +133,34 @@ TEST_CASE("[Image] Saving and loading") {
CHECK_MESSAGE(
image_jpg->load_jpg_from_buffer(data_jpg) == OK,
"The JPG image should load successfully.");
Ref<Image> image_grayscale_jpg = memnew(Image());
Ref<FileAccess> f_grayscale_jpg = FileAccess::open(TestUtils::get_data_path("images/grayscale.jpg"), FileAccess::READ, &err);
REQUIRE(f_grayscale_jpg.is_valid());
PackedByteArray data_grayscale_jpg;
data_grayscale_jpg.resize(f_grayscale_jpg->get_length() + 1);
f_grayscale_jpg->get_buffer(data_grayscale_jpg.ptrw(), f_grayscale_jpg->get_length());
CHECK_MESSAGE(
image_jpg->load_jpg_from_buffer(data_grayscale_jpg) == OK,
"The grayscale JPG image should load successfully.");
// Save JPG
const String save_path_jpg = TestUtils::get_temp_path("image.jpg");
CHECK_MESSAGE(image->save_jpg(save_path_jpg) == OK,
"The image should be saved successfully as a .jpg file.");
#ifdef MODULE_SVG_ENABLED
// Load SVG with embedded jpg image
Ref<Image> image_svg = memnew(Image());
Ref<FileAccess> f_svg = FileAccess::open(TestUtils::get_data_path("images/embedded_jpg.svg"), FileAccess::READ, &err);
REQUIRE(f_svg.is_valid());
PackedByteArray data_svg;
data_svg.resize(f_svg->get_length() + 1);
f_svg->get_buffer(data_svg.ptrw(), f_svg->get_length());
CHECK_MESSAGE(
image_svg->load_svg_from_buffer(data_svg) == OK,
"The SVG image should load successfully.");
#endif // MODULE_SVG_ENABLED
#endif // MODULE_JPG_ENABLED
#ifdef MODULE_WEBP_ENABLED

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B