X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fimage_test.cc;h=8d934bdd62fd429b77e454daf4fcc7917b7e1676;hb=266e3f1b80d1263ff3cc8b3afaecd6ca1f88983b;hp=7369bd24feac9ec03e4a21d2fb86aaa8bef7389d;hpb=952084c4221c5708e02c783284cf0f7239c6b4c4;p=dcpomatic.git diff --git a/test/image_test.cc b/test/image_test.cc index 7369bd24f..8d934bdd6 100644 --- a/test/image_test.cc +++ b/test/image_test.cc @@ -30,6 +30,8 @@ #include "lib/image.h" #include "lib/image_content.h" #include "lib/image_decoder.h" +#include "lib/image_jpeg.h" +#include "lib/image_png.h" #include "lib/ffmpeg_image_proxy.h" #include "test.h" #include @@ -375,14 +377,27 @@ BOOST_AUTO_TEST_CASE (as_png_test) auto proxy = make_shared("test/data/3d_test/000001.png"); auto image_rgb = proxy->image(Image::Alignment::PADDED).image; auto image_bgr = image_rgb->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_BGRA, Image::Alignment::PADDED, false); - image_rgb->as_png().write ("build/test/as_png_rgb.png"); - image_bgr->as_png().write ("build/test/as_png_bgr.png"); + image_as_png(image_rgb).write ("build/test/as_png_rgb.png"); + image_as_png(image_bgr).write ("build/test/as_png_bgr.png"); check_image ("test/data/3d_test/000001.png", "build/test/as_png_rgb.png"); check_image ("test/data/3d_test/000001.png", "build/test/as_png_bgr.png"); } +BOOST_AUTO_TEST_CASE (as_jpeg_test) +{ + auto proxy = make_shared("test/data/3d_test/000001.png"); + auto image_rgb = proxy->image(Image::Alignment::PADDED).image; + auto image_bgr = image_rgb->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_BGRA, Image::Alignment::PADDED, false); + image_as_jpeg(image_rgb, 60).write("build/test/as_jpeg_rgb.jpeg"); + image_as_jpeg(image_bgr, 60).write("build/test/as_jpeg_bgr.jpeg"); + + check_image ("test/data/as_jpeg_rgb.jpeg", "build/test/as_jpeg_rgb.jpeg"); + check_image ("test/data/as_jpeg_bgr.jpeg", "build/test/as_jpeg_bgr.jpeg"); +} + + /* Very dumb test to fade black to make sure it stays black */ static void fade_test_format_black (AVPixelFormat f, string name) @@ -391,7 +406,7 @@ fade_test_format_black (AVPixelFormat f, string name) yuv.make_black (); yuv.fade (0); string const filename = "fade_test_black_" + name + ".png"; - yuv.convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_RGBA, Image::Alignment::PADDED, false)->as_png().write("build/test/" + filename); + image_as_png(yuv.convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_RGBA, Image::Alignment::PADDED, false)).write("build/test/" + filename); check_image ("test/data/" + filename, "build/test/" + filename); } @@ -404,7 +419,7 @@ fade_test_format_red (AVPixelFormat f, float amount, string name) auto red = proxy->image(Image::Alignment::PADDED).image->convert_pixel_format(dcp::YUVToRGB::REC709, f, Image::Alignment::PADDED, false); red->fade (amount); string const filename = "fade_test_red_" + name + ".png"; - red->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_RGBA, Image::Alignment::PADDED, false)->as_png().write("build/test/" + filename); + image_as_png(red->convert_pixel_format(dcp::YUVToRGB::REC709, AV_PIX_FMT_RGBA, Image::Alignment::PADDED, false)).write("build/test/" + filename); check_image ("test/data/" + filename, "build/test/" + filename); }