+ Rect frame = { 0 , 0 , iconSize , iconSize } ;
+ Rect imageBounds = frame ;
+ GetPortBounds( image , &imageBounds ) ;
+
+ int bwSize = iconSize / 8 * iconSize ;
+ CIconHandle icon = (CIconHandle) NewHandleClear( sizeof ( CIcon ) + 2 * bwSize) ;
+ HLock((Handle)icon) ;
+ SetupCIconHandlePixMap( icon , dstDepth , &frame,GetCTable(dstDepth)) ;
+ HLock( (**icon).iconData ) ;
+ (**icon).iconPMap.baseAddr = *(**icon).iconData ;
+
+ LockPixels(GetGWorldPixMap(image));
+
+ CopyBits(GetPortBitMapForCopyBits(image),
+ (BitMapPtr)&((**icon).iconPMap),
+ &imageBounds,
+ &imageBounds,
+ srcCopy | ditherCopy, nil);
+
+
+ UnlockPixels(GetGWorldPixMap(image));
+ HUnlock( (**icon).iconData ) ;
+
+ (**icon).iconMask.rowBytes = iconSize / 8 ;
+ (**icon).iconMask.bounds = frame ;
+
+ (**icon).iconBMap.rowBytes = iconSize / 8 ;
+ (**icon).iconBMap.bounds = frame ;
+ (**icon).iconMask.baseAddr = (char*) &(**icon).iconMaskData ;
+ (**icon).iconBMap.baseAddr = (char*) &(**icon).iconMaskData + bwSize ;
+
+ if ( mask )
+ {
+ LockPixels(GetGWorldPixMap(mask) ) ;
+ CopyBits(GetPortBitMapForCopyBits(mask) ,
+ &(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
+ CopyBits(GetPortBitMapForCopyBits(mask) ,
+ &(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
+ UnlockPixels(GetGWorldPixMap( mask ) ) ;
+ }
+ else
+ {
+ LockPixels(GetGWorldPixMap(image));
+ CopyBits(GetPortBitMapForCopyBits(image) ,
+ &(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
+ CopyBits(GetPortBitMapForCopyBits(image) ,
+ &(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
+ UnlockPixels(GetGWorldPixMap(image));
+ }
+
+ (**icon).iconMask.baseAddr = NULL ;
+ (**icon).iconBMap.baseAddr = NULL ;
+ (**icon).iconPMap.baseAddr = NULL ;
+ HUnlock((Handle)icon) ;
+ SetGWorld(saveWorld,saveHandle);
+
+ return icon;
+}
+
+PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
+{
+ CGrafPtr origPort ;
+ GDHandle origDev ;
+
+ PicHandle pict;
+
+ RGBColor white = { 0xffff ,0xffff , 0xffff } ;
+ RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;