- GWorldPtr monoworld ;
- clipRgn = NewRgn() ;
- OSStatus err = NewGWorld( &monoworld , 1 , &rect , NULL , NULL , 0 ) ;
- verify_noerr(err) ;
- LockPixels( GetGWorldPixMap( monoworld ) ) ;
- LockPixels( GetGWorldPixMap( mask ) ) ;
- SetGWorld( monoworld , NULL ) ;
-
- RGBColor white = { 0xffff , 0xffff , 0xffff } ;
- RGBColor black = { 0x0000 , 0x0000 , 0x0000 } ;
- RGBForeColor( &black ) ;
- RGBBackColor( &white ) ;
-
- CopyBits(GetPortBitMapForCopyBits(mask),
- GetPortBitMapForCopyBits(monoworld),
- &rect,
- &rect,
- srcCopy, NULL);
- BitMapToRegion( clipRgn , (BitMap*) *GetGWorldPixMap( monoworld ) ) ;
-
- UnlockPixels( GetGWorldPixMap( monoworld ) ) ;
- UnlockPixels( GetGWorldPixMap( mask ) ) ;
- DisposeGWorld( monoworld ) ;
- }
-
- SetGWorld( wp , NULL ) ;
- Rect portRect ;
- GetPortBounds( wp , &portRect ) ;
- m_pictHandle = OpenPicture(&portRect);
-
- if (m_pictHandle)
- {
- RGBColor white = { 0xffff , 0xffff , 0xffff } ;
- RGBColor black = { 0x0000 , 0x0000 , 0x0000 } ;
-
- RGBForeColor( &black ) ;
- RGBBackColor( &white ) ;
-
- if ( clipRgn )
- SetClip( clipRgn ) ;
-
- LockPixels( GetGWorldPixMap( wp ) ) ;
- CopyBits(GetPortBitMapForCopyBits(wp),
- GetPortBitMapForCopyBits(wp),
- &portRect,
- &portRect,
- srcCopy,clipRgn);
- UnlockPixels( GetGWorldPixMap( wp ) ) ;
- ClosePicture();
+ m_pictHandle = (PicHandle) NewHandle(0);
+ if ( m_pictHandle )
+ {
+ // QT does not correctly export the mask
+ // TODO if we get around to it create a synthetic PICT with the CopyBits and Mask commands
+ CGImageRef imageRef = CreateCGImage();
+ err = GraphicsExportSetInputCGImage( exporter, imageRef );
+ err = GraphicsExportSetOutputHandle(exporter, (Handle)m_pictHandle);
+ err = GraphicsExportDoExport(exporter, NULL);
+ CGImageRelease( imageRef );
+
+ size_t handleSize = GetHandleSize( (Handle) m_pictHandle );
+ // the 512 bytes header is only needed for pict files, but not in memory
+ if ( handleSize >= 512 )
+ {
+ memmove( *m_pictHandle , (char*)(*m_pictHandle)+512, handleSize - 512 );
+ SetHandleSize( (Handle) m_pictHandle, handleSize - 512 );
+ }
+ }
+ CloseComponent( exporter );