Index: cairo_helper.cxx
===================================================================
RCS file: /cvs/gsl/canvas/source/cairo/cairo_helper.cxx,v
retrieving revision 1.2
diff -u -p -r1.2 cairo_helper.cxx
--- canvas/source/cairo/cairo_helper.cxx	28 Feb 2006 10:35:47 -0000	1.2
+++ canvas/source/cairo/cairo_helper.cxx	9 Aug 2006 16:29:37 -0000
@@ -154,13 +154,16 @@ cairoHelperFlush( const void* pSysDataVo
 void*
 cairoHelperGetSurface( const void* pSysDataVoid, const void* pBmpDataVoid, int width, int height )
 {
-	const BitmapSystemData* pBmpData = (const BitmapSystemData*) pBmpDataVoid;
-	const SystemEnvData* pSysData = (const SystemEnvData*) pSysDataVoid;
+    const BitmapSystemData* pBmpData = (const BitmapSystemData*) pBmpDataVoid;
+    const SystemEnvData* pSysData = (const SystemEnvData*) pSysDataVoid;
 
-	return cairo_xlib_surface_create( (Display*) pSysData->pDisplay,
-					  (Drawable) pBmpData->aPixmap,
-					  (Visual*) pSysData->pVisual,
-					  width, height );
+    if( pBmpData->mnWidth != width || pBmpData->mnHeight != height )
+        return NULL;
+
+    return cairo_xlib_surface_create( (Display*) pSysData->pDisplay,
+                                      (Drawable) pBmpData->aPixmap,
+                                      (Visual*) pSysData->pVisual,
+                                      width, height );
 }
 
 void*
Index: cairo_devicehelper.cxx
===================================================================
RCS file: /cvs/gsl/canvas/source/cairo/cairo_devicehelper.cxx,v
retrieving revision 1.3
diff -u -p -r1.3 cairo_devicehelper.cxx
--- canvas/source/cairo/cairo_devicehelper.cxx	22 Mar 2006 11:00:26 -0000	1.3
+++ canvas/source/cairo/cairo_devicehelper.cxx	9 Aug 2006 16:32:13 -0000
@@ -375,7 +375,19 @@ namespace cairocanvas
 
     Surface* DeviceHelper::getSurface( BitmapSystemData& rData, const Size& rSize )
     {
+#ifdef CAIRO_HAS_WIN32_SURFACE
+        if (rData.pDIB != NULL) {
+            // Using cairo will not work anyway, as most (?) DIBs that come here
+            // will be upside-down and different order of colour channels
+            // compared to what cairo expects. 
+           return NULL;
+        }
+#endif
-		return new Surface ( mpSysData, &rData, rSize.Width(), rSize.Height() );
+        OSL_TRACE( "requested size: %d x %d available size: %d x %d", rSize.Width (), rSize.Height (), rData.mnWidth, rData.mnHeight );
+        if ( rData.mnWidth == rSize.Width() && rData.mnHeight == rSize.Height() )
+            return new Surface ( mpSysData, &rData, rSize.Width(), rSize.Height() );
+        else
+            return NULL;
     }
 
     void DeviceHelper::flush()
