Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3D21CD37D for ; Fri, 27 Jul 2012 15:02:04 +0000 (UTC) Received: (qmail 48415 invoked by uid 500); 27 Jul 2012 15:02:04 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 48380 invoked by uid 500); 27 Jul 2012 15:02:04 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 48372 invoked by uid 99); 27 Jul 2012 15:02:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jul 2012 15:02:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jul 2012 15:02:02 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 47E1523888E4; Fri, 27 Jul 2012 15:01:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1366403 - /incubator/ooo/trunk/main/svtools/source/filter/wmf/enhwmf.cxx Date: Fri, 27 Jul 2012 15:01:19 -0000 To: ooo-commits@incubator.apache.org From: alg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120727150119.47E1523888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: alg Date: Fri Jul 27 15:01:18 2012 New Revision: 1366403 URL: http://svn.apache.org/viewvc?rev=1366403&view=rev Log: #119450# Added EMR_ALPHABLEND case to EnhWMFReader to correct visualisations Patch by: Jianyuan Li Review by: alg Modified: incubator/ooo/trunk/main/svtools/source/filter/wmf/enhwmf.cxx Modified: incubator/ooo/trunk/main/svtools/source/filter/wmf/enhwmf.cxx URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svtools/source/filter/wmf/enhwmf.cxx?rev=1366403&r1=1366402&r2=1366403&view=diff ============================================================================== --- incubator/ooo/trunk/main/svtools/source/filter/wmf/enhwmf.cxx (original) +++ incubator/ooo/trunk/main/svtools/source/filter/wmf/enhwmf.cxx Fri Jul 27 15:01:18 2012 @@ -168,6 +168,21 @@ static float GetSwapFloat( SvStream& rSt } #endif +struct BLENDFUNCTION{ + unsigned char aBlendOperation; + unsigned char aBlendFlags; + unsigned char aSrcConstantAlpha; + unsigned char aAlphaFormat; + + friend SvStream& operator>>( SvStream& rIn, BLENDFUNCTION& rBlendFun ); +}; + +SvStream& operator>>( SvStream& rIn, BLENDFUNCTION& rBlendFun ) +{ + rIn >> rBlendFun.aBlendOperation >> rBlendFun.aBlendFlags >> + rBlendFun.aSrcConstantAlpha >> rBlendFun.aAlphaFormat; + return rIn; +} SvStream& operator>>( SvStream& rIn, XForm& rXForm ) { if ( sizeof( float ) != 4 ) @@ -805,7 +820,63 @@ sal_Bool EnhWMFReader::ReadEnhWMF() pOut->SetClipPath( aPolyPoly, iMode, sal_False ); } break; + case EMR_ALPHABLEND: + { + sal_Int32 xDest, yDest, cxDest, cyDest; + + BLENDFUNCTION aFunc; + sal_Int32 xSrc, ySrc; + XForm xformSrc; + sal_uInt32 BkColorSrc,iUsageSrc ,offBmiSrc,cbBmiSrc,offBitsSrc,cbBitsSrc ,cxSrc,cySrc ; + sal_uInt32 nStart = pWMF->Tell() - 8; + pWMF->SeekRel( 0x10 ); + + *pWMF >> xDest >> yDest >> cxDest >> cyDest >> aFunc >> xSrc >> ySrc + >> xformSrc >> BkColorSrc >> iUsageSrc >> offBmiSrc >> cbBmiSrc + >> offBitsSrc >> cbBitsSrc >>cxSrc>>cySrc ; + + sal_uInt32 dwRop = SRCAND|SRCINVERT; + + Bitmap aBitmap; + Rectangle aRect( Point( xDest, yDest ), Size( cxDest+1, cyDest+1 ) ); + + if ( (cbBitsSrc > (SAL_MAX_UINT32 - 14)) || ((SAL_MAX_UINT32 - 14) - cbBitsSrc < cbBmiSrc) ) + bStatus = sal_False; + else + { + sal_uInt32 nSize = cbBmiSrc + cbBitsSrc + 14; + if ( nSize <= ( nEndPos - nStartPos ) ) + { + char* pBuf = new char[ nSize ]; + SvMemoryStream aTmp( pBuf, nSize, STREAM_READ | STREAM_WRITE ); + aTmp.ObjectOwnsMemory( sal_True ); + aTmp << (sal_uInt8)'B' + << (sal_uInt8)'M' + << (sal_uInt32)cbBitsSrc + << (sal_uInt16)0 + << (sal_uInt16)0 + << (sal_uInt32)cbBmiSrc + 14; + pWMF->Seek( nStart + offBmiSrc ); + pWMF->Read( pBuf + 14, cbBmiSrc ); + pWMF->Seek( nStart + offBitsSrc ); + pWMF->Read( pBuf + 14 + cbBmiSrc, cbBitsSrc ); + aTmp.Seek( 0 ); + aBitmap.Read( aTmp, sal_True ); + // test if it is sensible to crop + if ( ( cxSrc > 0 ) && ( cySrc > 0 ) && + ( xSrc >= 0 ) && ( ySrc >= 0 ) && + ( xSrc + cxSrc <= aBitmap.GetSizePixel().Width() ) && + ( ySrc + cySrc <= aBitmap.GetSizePixel().Height() ) ) + { + Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) ); + aBitmap.Crop( aCropRect ); + } + aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop ), LIST_APPEND ); + } + } + } + break; case EMR_BITBLT : // PASSTHROUGH INTENDED case EMR_STRETCHBLT : { @@ -1225,7 +1296,6 @@ sal_Bool EnhWMFReader::ReadEnhWMF() case EMR_COLORCORRECTPALETTE : WinMtfAssertHandler( "ColorCorrectPalette" ); break; case EMR_SETICMPROFILEA : WinMtfAssertHandler( "SetICMProfileA" ); break; case EMR_SETICMPROFILEW : WinMtfAssertHandler( "SetICMProfileW" ); break; - case EMR_ALPHABLEND : WinMtfAssertHandler( "Alphablend" ); break; case EMR_TRANSPARENTBLT : WinMtfAssertHandler( "TransparenBlt" ); break; case EMR_TRANSPARENTDIB : WinMtfAssertHandler( "TransparenDib" ); break; case EMR_GRADIENTFILL : WinMtfAssertHandler( "GradientFill" ); break;