summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-08-24 13:53:38 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-08-29 15:08:15 +0200
commit91653df0bf9abad5d67635db6576a559f742576c (patch)
tree984f766845217bbfd6d40b415a8a086c8b8851e6
parentdc94c82f67369219b69a0daa34c055eea28dfb5c (diff)
Related: tdf#149971 svx: support explicitly provided snapshots for media shapes
Snapshots / previews for media objects are used when the shape's video is not playing. This is generated by seeking to the 3rd second in the video, probably to avoid initial black frames. The trouble is that PowerPoint takes the initial frame (at least in case of the bugdoc), so our snapshot doesn't match the reference. We already import a bitmap snapshot from PPTX files since commit e2d46da076f43a7c0d56fc486b9f15339243f7c9 (avmedia: add doc model for bitmap fill of slide narrations, 2021-01-21), fix the problem by changing the snapshot generation to prefer this bitmap over generating one from the video. The crop properties of this bitmap / the video are still not yet handled from PPTX. (cherry picked from commit 8fa1d453c94cdbb03dac646fb8db2ebd1a0e84bd) Change-Id: Id985eaaaad5e4222d9a98203d054e08a0f97a0f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138967 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--svx/qa/unit/data/video-snapshot.pptxbin0 -> 40194 bytes
-rw-r--r--svx/qa/unit/svdraw.cxx23
-rw-r--r--svx/source/svdraw/svdomedia.cxx9
3 files changed, 32 insertions, 0 deletions
diff --git a/svx/qa/unit/data/video-snapshot.pptx b/svx/qa/unit/data/video-snapshot.pptx
new file mode 100644
index 000000000000..9a0ec9ebd867
--- /dev/null
+++ b/svx/qa/unit/data/video-snapshot.pptx
Binary files differ
diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx
index ae673af298b3..17376b8e74d5 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -36,6 +36,7 @@
#include <comphelper/propertyvalue.hxx>
#include <sfx2/viewsh.hxx>
#include <svl/itempool.hxx>
+#include <svx/svdomedia.hxx>
#include <sdr/contact/objectcontactofobjlistpainter.hxx>
@@ -471,6 +472,28 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testMaterialSpecular)
// has specularity=77%. It should be specularIntensity = 100-77=23 with patch.
assertXPath(pXmlDoc, "(//material)[1]", "specularIntensity", "23");
}
+
+CPPUNIT_TEST_FIXTURE(SvdrawTest, testVideoSnapshot)
+{
+ // Given a slide with a media shape, containing a 4 sec video, red-green-blue-black being the 4
+ // seconds:
+ OUString aURL = m_directories.getURLFromSrc(u"svx/qa/unit/data/video-snapshot.pptx");
+ mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument");
+ SdrPage* pSdrPage = getFirstDrawPageWithAssert();
+ auto pSdrMediaObj = dynamic_cast<SdrMediaObj*>(pSdrPage->GetObj(0));
+
+ // When getting the red snapshot of the video:
+ Graphic aSnapshot(pSdrMediaObj->getSnapshot());
+
+ // Then make sure the color is correct:
+ const BitmapEx& rBitmap = aSnapshot.GetBitmapExRef();
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: rgba[ff0000ff]
+ // - Actual : rgba[000000ff]
+ // i.e. the preview was black, not red; since we seeked 3 secs into the video, while PowerPoint
+ // doesn't do that.
+ CPPUNIT_ASSERT_EQUAL(Color(0xff, 0x0, 0x0), rBitmap.GetPixelColor(0, 0));
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index bc030c7d6d3f..96d12027a060 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -143,6 +143,15 @@ uno::Reference< graphic::XGraphic > const & SdrMediaObj::getSnapshot() const
#if HAVE_FEATURE_AVMEDIA
if( !m_xImpl->m_xCachedSnapshot.is() )
{
+ Graphic aGraphic = m_xImpl->m_MediaProperties.getGraphic();
+ if (!aGraphic.IsNone())
+ {
+ // We have an explicit graphic for this media object, then go with that instead of
+ // generating our own one.
+ m_xImpl->m_xCachedSnapshot = aGraphic.GetXGraphic();
+ return m_xImpl->m_xCachedSnapshot;
+ }
+
OUString aRealURL = m_xImpl->m_MediaProperties.getTempURL();
if( aRealURL.isEmpty() )
aRealURL = m_xImpl->m_MediaProperties.getURL();