From c9fab49302f4ed44e3ef3edbcafc43002d496796 Mon Sep 17 00:00:00 2001 From: "Oleg.Korshul" Date: Mon, 24 Feb 2014 10:05:28 +0000 Subject: [PATCH] (1.0.0.9) metafile git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@54587 954022d7-b5bf-4e40-9824-e11837661b57 --- OfficeCore/Images/ImageGdipFile.h | 31 +++++++++++++++++++++++++++++++ OfficeCore/OfficeCore.vcproj | 2 +- OfficeCore/version.h | 6 +++--- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/OfficeCore/Images/ImageGdipFile.h b/OfficeCore/Images/ImageGdipFile.h index cfdd353148..b6b471958d 100644 --- a/OfficeCore/Images/ImageGdipFile.h +++ b/OfficeCore/Images/ImageGdipFile.h @@ -283,6 +283,37 @@ public: { ImageUtils::GdiPlusBitmapToMediaData(&oBitmap, &m_pFrame); } + else + { + Metafile oMeta(bsFileName); + UINT lSrcW = oMeta.GetWidth(); + UINT lSrcH = oMeta.GetHeight(); + + if (oMeta.GetLastStatus() == Gdiplus::Ok && lSrcW > 0 && lSrcH > 0) + { + UINT lMaxSize = 1000; + LONG lDstW = lSrcW; + LONG lDstH = lSrcH; + if (lSrcW > lMaxSize || lSrcH > lMaxSize) + { + double dKoef1 = (double)lMaxSize / lSrcW; + double dKoef2 = (double)lMaxSize / lSrcH; + double dKoef = min(dKoef1, dKoef2); + + lDstW = (LONG)(dKoef * lSrcW); + lDstH = (LONG)(dKoef * lSrcH); + + Bitmap oBitmapMeta(lDstW, lDstH, PixelFormat32bppARGB); + Graphics oGraphics(&oBitmapMeta); + oGraphics.DrawImage(&oMeta, 0, 0, lDstW, lDstH); + + if (oBitmapMeta.GetLastStatus() == Gdiplus::Ok) + { + ImageUtils::GdiPlusBitmapToMediaData(&oBitmapMeta, &m_pFrame); + } + } + } + } } catch(...) { diff --git a/OfficeCore/OfficeCore.vcproj b/OfficeCore/OfficeCore.vcproj index b4bd5952df..ffbc2b0df9 100644 --- a/OfficeCore/OfficeCore.vcproj +++ b/OfficeCore/OfficeCore.vcproj @@ -227,7 +227,7 @@