mirror of
https://github.com/schrodinger/pymol-open-source.git
synced 2026-06-03 19:54:24 +08:00
PYMOL-3191 fix Image::interlace() and ScenePNG
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 3.4 KiB |
BIN
data/test/single-right.png
Normal file
BIN
data/test/single-right.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -144,16 +144,19 @@ public:
|
||||
|
||||
Image interlace() const
|
||||
{
|
||||
Image newImg(m_width, m_height);
|
||||
auto half_width = m_width / 2u;
|
||||
if (!m_stereo || (m_width % 2 == 1)) {
|
||||
throw ill_informed_image{};
|
||||
}
|
||||
|
||||
Image newImg(m_width * 2, m_height);
|
||||
auto* src = pixels();
|
||||
auto* dst = newImg.pixels();
|
||||
auto* dst_end = dst + m_width * m_height;
|
||||
const unsigned int* src_half = src + (m_height * half_width);
|
||||
auto* dst_end = dst + (m_width * 2 * m_height);
|
||||
auto offset = m_width * m_height;
|
||||
|
||||
for (; dst != dst_end; src += half_width, src_half += half_width) {
|
||||
dst = std::copy(src, src + half_width, dst);
|
||||
dst = std::copy(src_half, src_half + half_width, dst);
|
||||
for (; dst != dst_end; src += m_width) {
|
||||
dst = std::copy_n(src, m_width, dst);
|
||||
dst = std::copy_n(src + offset, m_width, dst);
|
||||
}
|
||||
return newImg;
|
||||
}
|
||||
|
||||
@@ -1828,7 +1828,8 @@ bool ScenePNG(PyMOLGlobals * G, const char *png, float dpi, int quiet,
|
||||
int width, height;
|
||||
std::tie(width, height) = I->Image->getSize();
|
||||
auto saveImage = I->Image;
|
||||
if(I->Image && I->StereoMode) {
|
||||
if(I->Image->isStereo()) {
|
||||
saveImage = std::make_shared<pymol::Image>();
|
||||
*(saveImage) = I->Image->interlace();
|
||||
}
|
||||
if(dpi < 0.0F)
|
||||
|
||||
@@ -207,11 +207,16 @@ TEST_CASE("Image Deinterlace Data", "[Image]")
|
||||
TEST_CASE("Image Interlace Data", "[Image]")
|
||||
{
|
||||
auto test_folder = std::string(std::getenv("PYMOL_DATA")).append(PATH_SEP).append("test").append(PATH_SEP);
|
||||
auto deinterlacedimage_loc = std::string(test_folder).append("single.png");
|
||||
auto interlacedimage_loc = std::string(test_folder).append("double.png");
|
||||
auto deinterlacedimage = MyPNGRead(deinterlacedimage_loc.c_str());
|
||||
auto interlacedimage = MyPNGRead(interlacedimage_loc.c_str());
|
||||
auto solution = deinterlacedimage->interlace();
|
||||
REQUIRE(solution.getSizeInBytes() == deinterlacedimage->getSizeInBytes());
|
||||
}
|
||||
|
||||
auto loc_left = std::string(test_folder).append("single.png");
|
||||
auto loc_right = std::string(test_folder).append("single-right.png");
|
||||
auto loc_double = std::string(test_folder).append("double.png");
|
||||
|
||||
auto img_stereo = MyPNGRead(loc_left.c_str());
|
||||
img_stereo->merge(*MyPNGRead(loc_right.c_str()));
|
||||
|
||||
auto img_double = MyPNGRead(loc_double.c_str());
|
||||
|
||||
REQUIRE(*img_stereo == img_double->deinterlace());
|
||||
REQUIRE(img_stereo->interlace() == *img_double);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user