You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by li...@apache.org on 2012/08/16 04:26:37 UTC

svn commit: r1373702 - /incubator/ooo/trunk/main/svtools/source/filter/wmf/enhwmf.cxx

Author: lijiany
Date: Thu Aug 16 02:26:37 2012
New Revision: 1373702

URL: http://svn.apache.org/viewvc?rev=1373702&view=rev
Log:
#119535# Fix WMF image with type pattern brush
Reported by: Du Jing
Patch by: Jianyuan Li
Review by: SunYing

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=1373702&r1=1373701&r2=1373702&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svtools/source/filter/wmf/enhwmf.cxx (original)
+++ incubator/ooo/trunk/main/svtools/source/filter/wmf/enhwmf.cxx Thu Aug 16 02:26:37 2012
@@ -1280,7 +1280,45 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
                 }
             }
             break;
-
+			case EMR_CREATEDIBPATTERNBRUSHPT :
+				sal_uInt32	nTmp32;
+				sal_uInt32  nOffset;
+				*pWMF >> nIndex;
+				Bitmap	aBmp;
+				BitmapReadAccess* pBmp;
+				sal_uInt32	nRed = 0, nGreen = 0, nBlue = 0, nCount = 1;
+
+				*pWMF >> nTmp32;
+				*pWMF >> nOffset;
+				for ( sal_Int32 i = 0; i < (nOffset - 20)/4; i ++ )
+				{
+					*pWMF >> nTmp32;
+				}
+
+				aBmp.Read( *pWMF, sal_False );
+				pBmp = aBmp.AcquireReadAccess();
+				if ( pBmp )
+				{
+					for ( sal_Int32 y = 0; y < pBmp->Height(); y++ )
+					{
+						for ( sal_Int32 x = 0; x < pBmp->Width(); x++ )
+						{
+							const BitmapColor aColor( pBmp->GetColor( y, x ) );						
+							
+							nRed += aColor.GetRed();
+							nGreen += aColor.GetGreen();
+							nBlue += aColor.GetBlue();
+						}
+					}
+					nCount = pBmp->Height() * pBmp->Width();
+					if ( !nCount )
+						nCount++;
+					aBmp.ReleaseAccess( pBmp );
+				}
+				Color aColor( (sal_Char)( nRed / nCount ), (sal_Char)( nGreen / nCount ), (sal_Char)( nBlue / nCount ) );
+				pOut->CreateObject( nIndex, GDI_BRUSH, new WinMtfFillStyle( aColor, sal_False ) );
+				
+			break;
 
 #ifdef WIN_MTF_ASSERT
             default :                           WinMtfAssertHandler( "Unknown Meta Action" );       break;