+ CGContextSetFillColorSpace( m_context, genericColorSpace );
+ CGContextSetStrokeColorSpace( m_context, genericColorSpace );
+
+ CGContextTranslateCTM( m_context , 0 , height ) ;
+ CGContextScaleCTM( m_context , 1 , -1 ) ;
+ }
+}
+
+wxMetafileRefData::~wxMetafileRefData()
+{
+}
+
+void wxMetafileRefData::Init()
+{
+ m_context = NULL;
+ m_width = -1;
+ m_height = -1;
+}
+
+void wxMetafileRefData::Close()
+{
+ CGPDFContextEndPage(m_context);
+
+ CGContextRelease(m_context);
+ m_context = NULL;
+
+ UpdateDocumentFromData();
+}
+
+void wxMetafileRefData::UpdateDocumentFromData()
+{
+ wxCFRef<CGDataProviderRef> provider(wxMacCGDataProviderCreateWithCFData(m_data));
+ m_pdfDoc.reset(CGPDFDocumentCreateWithProvider(provider));
+ if ( m_pdfDoc != NULL )
+ {
+ CGPDFPageRef page = CGPDFDocumentGetPage( m_pdfDoc, 1 );
+ CGRect rect = CGPDFPageGetBoxRect ( page, kCGPDFMediaBox);
+ m_width = wx_static_cast(int, rect.size.width);
+ m_height = wx_static_cast(int, rect.size.height);
+ }
+}