mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Use libjpeg-turbo for improved jpg compatibility and speed
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
This commit is contained in:
committed by
Rémi Verschelde
parent
cc948984ad
commit
a0cc41b5ed
@@ -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
|
||||
|
||||
1
tests/data/images/embedded_jpg.svg
Normal file
1
tests/data/images/embedded_jpg.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 20 KiB |
BIN
tests/data/images/grayscale.jpg
Normal file
BIN
tests/data/images/grayscale.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 216 B |
Reference in New Issue
Block a user