compile fix for bitmap.cpp under Mac
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13227 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -10,7 +10,6 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "bitmapbase.h"
|
|
||||||
#pragma implementation "bitmap.h"
|
#pragma implementation "bitmap.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -36,75 +35,75 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject )
|
|||||||
|
|
||||||
CTabHandle wxMacCreateColorTable( int numColors )
|
CTabHandle wxMacCreateColorTable( int numColors )
|
||||||
{
|
{
|
||||||
CTabHandle newColors; /* Handle to the new color table */
|
CTabHandle newColors; /* Handle to the new color table */
|
||||||
|
|
||||||
/* Allocate memory for the color table */
|
/* Allocate memory for the color table */
|
||||||
newColors = (CTabHandle)NewHandleClear( sizeof (ColorTable) +
|
newColors = (CTabHandle)NewHandleClear( sizeof (ColorTable) +
|
||||||
sizeof (ColorSpec) * (numColors - 1) );
|
sizeof (ColorSpec) * (numColors - 1) );
|
||||||
if (newColors != nil)
|
if (newColors != nil)
|
||||||
{
|
{
|
||||||
/* Initialize the fields */
|
/* Initialize the fields */
|
||||||
(**newColors).ctSeed = GetCTSeed();
|
(**newColors).ctSeed = GetCTSeed();
|
||||||
(**newColors).ctFlags = 0;
|
(**newColors).ctFlags = 0;
|
||||||
(**newColors).ctSize = numColors - 1;
|
(**newColors).ctSize = numColors - 1;
|
||||||
/* Initialize the table of colors */
|
/* Initialize the table of colors */
|
||||||
}
|
}
|
||||||
return newColors ;
|
return newColors ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacDestroyColorTable( CTabHandle colors )
|
void wxMacDestroyColorTable( CTabHandle colors )
|
||||||
{
|
{
|
||||||
DisposeHandle( (Handle) colors ) ;
|
DisposeHandle( (Handle) colors ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue )
|
void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue )
|
||||||
{
|
{
|
||||||
(**newColors).ctTable[index].value = index;
|
(**newColors).ctTable[index].value = index;
|
||||||
(**newColors).ctTable[index].rgb.red = 0 ;// someRedValue;
|
(**newColors).ctTable[index].rgb.red = 0 ;// someRedValue;
|
||||||
(**newColors).ctTable[index].rgb.green = 0 ; // someGreenValue;
|
(**newColors).ctTable[index].rgb.green = 0 ; // someGreenValue;
|
||||||
(**newColors).ctTable[index].rgb.blue = 0 ; // someBlueValue;
|
(**newColors).ctTable[index].rgb.blue = 0 ; // someBlueValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GWorldPtr wxMacCreateGWorld( int width , int height , int depth )
|
GWorldPtr wxMacCreateGWorld( int width , int height , int depth )
|
||||||
{
|
{
|
||||||
OSErr err = noErr ;
|
OSErr err = noErr ;
|
||||||
GWorldPtr port ;
|
GWorldPtr port ;
|
||||||
Rect rect = { 0 , 0 , height , width } ;
|
Rect rect = { 0 , 0 , height , width } ;
|
||||||
|
|
||||||
if ( depth < 0 )
|
if ( depth < 0 )
|
||||||
{
|
{
|
||||||
depth = wxDisplayDepth() ;
|
depth = wxDisplayDepth() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = NewGWorld( &port , depth , &rect , NULL , NULL , 0 ) ;
|
err = NewGWorld( &port , depth , &rect , NULL , NULL , 0 ) ;
|
||||||
if ( err == noErr )
|
if ( err == noErr )
|
||||||
{
|
{
|
||||||
return port ;
|
return port ;
|
||||||
}
|
}
|
||||||
return NULL ;
|
return NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacDestroyGWorld( GWorldPtr gw )
|
void wxMacDestroyGWorld( GWorldPtr gw )
|
||||||
{
|
{
|
||||||
if ( gw )
|
if ( gw )
|
||||||
DisposeGWorld( gw ) ;
|
DisposeGWorld( gw ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define kDefaultRes 0x00480000 /* Default resolution is 72 DPI; Fixed type */
|
#define kDefaultRes 0x00480000 /* Default resolution is 72 DPI; Fixed type */
|
||||||
|
|
||||||
OSErr SetupCIconHandlePixMap( CIconHandle icon , short depth , Rect *bounds , CTabHandle colors )
|
OSErr SetupCIconHandlePixMap( CIconHandle icon , short depth , Rect *bounds , CTabHandle colors )
|
||||||
{
|
{
|
||||||
CTabHandle newColors; /* Color table used for the off-screen PixMap */
|
CTabHandle newColors; /* Color table used for the off-screen PixMap */
|
||||||
Ptr offBaseAddr; /* Pointer to the off-screen pixel image */
|
Ptr offBaseAddr; /* Pointer to the off-screen pixel image */
|
||||||
OSErr error; /* Returns error code */
|
OSErr error; /* Returns error code */
|
||||||
short bytesPerRow; /* Number of bytes per row in the PixMap */
|
short bytesPerRow; /* Number of bytes per row in the PixMap */
|
||||||
|
|
||||||
|
|
||||||
error = noErr;
|
error = noErr;
|
||||||
newColors = nil;
|
newColors = nil;
|
||||||
offBaseAddr = nil;
|
offBaseAddr = nil;
|
||||||
|
|
||||||
bytesPerRow = ((depth * (bounds->right - bounds->left) + 31) / 32) * 4;
|
bytesPerRow = ((depth * (bounds->right - bounds->left) + 31) / 32) * 4;
|
||||||
|
|
||||||
/* Clone the clut if indexed color; allocate a dummy clut if direct color*/
|
/* Clone the clut if indexed color; allocate a dummy clut if direct color*/
|
||||||
if (depth <= 8)
|
if (depth <= 8)
|
||||||
@@ -180,15 +179,15 @@ OSErr SetupCIconHandlePixMap( CIconHandle icon , short depth , Rect *bounds , C
|
|||||||
|
|
||||||
CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize )
|
CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize )
|
||||||
{
|
{
|
||||||
GWorldPtr saveWorld;
|
GWorldPtr saveWorld;
|
||||||
GDHandle saveHandle;
|
GDHandle saveHandle;
|
||||||
|
|
||||||
GetGWorld(&saveWorld,&saveHandle); // save Graphics env state
|
GetGWorld(&saveWorld,&saveHandle); // save Graphics env state
|
||||||
SetGWorld(image,nil);
|
SetGWorld(image,nil);
|
||||||
|
|
||||||
Rect frame = { 0 , 0 , iconSize , iconSize } ;
|
Rect frame = { 0 , 0 , iconSize , iconSize } ;
|
||||||
Rect imageBounds = frame ;
|
Rect imageBounds = frame ;
|
||||||
GetPortBounds( image , &imageBounds ) ;
|
GetPortBounds( image , &imageBounds ) ;
|
||||||
|
|
||||||
int bwSize = iconSize / 8 * iconSize ;
|
int bwSize = iconSize / 8 * iconSize ;
|
||||||
CIconHandle icon = (CIconHandle) NewHandleClear( sizeof ( CIcon ) + 2 * bwSize) ;
|
CIconHandle icon = (CIconHandle) NewHandleClear( sizeof ( CIcon ) + 2 * bwSize) ;
|
||||||
@@ -197,16 +196,16 @@ CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth ,
|
|||||||
HLock( (**icon).iconData ) ;
|
HLock( (**icon).iconData ) ;
|
||||||
(**icon).iconPMap.baseAddr = *(**icon).iconData ;
|
(**icon).iconPMap.baseAddr = *(**icon).iconData ;
|
||||||
|
|
||||||
LockPixels(GetGWorldPixMap(image));
|
LockPixels(GetGWorldPixMap(image));
|
||||||
|
|
||||||
CopyBits(GetPortBitMapForCopyBits(image),
|
CopyBits(GetPortBitMapForCopyBits(image),
|
||||||
(BitMapPtr)&((**icon).iconPMap),
|
(BitMapPtr)&((**icon).iconPMap),
|
||||||
&imageBounds,
|
&imageBounds,
|
||||||
&imageBounds,
|
&imageBounds,
|
||||||
srcCopy | ditherCopy, nil);
|
srcCopy | ditherCopy, nil);
|
||||||
|
|
||||||
|
|
||||||
UnlockPixels(GetGWorldPixMap(image));
|
UnlockPixels(GetGWorldPixMap(image));
|
||||||
HUnlock( (**icon).iconData ) ;
|
HUnlock( (**icon).iconData ) ;
|
||||||
|
|
||||||
(**icon).iconMask.rowBytes = iconSize / 8 ;
|
(**icon).iconMask.rowBytes = iconSize / 8 ;
|
||||||
@@ -228,21 +227,21 @@ CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth ,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LockPixels(GetGWorldPixMap(image));
|
LockPixels(GetGWorldPixMap(image));
|
||||||
CopyBits(GetPortBitMapForCopyBits(image) ,
|
CopyBits(GetPortBitMapForCopyBits(image) ,
|
||||||
&(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
||||||
CopyBits(GetPortBitMapForCopyBits(image) ,
|
CopyBits(GetPortBitMapForCopyBits(image) ,
|
||||||
&(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
||||||
UnlockPixels(GetGWorldPixMap(image));
|
UnlockPixels(GetGWorldPixMap(image));
|
||||||
}
|
}
|
||||||
|
|
||||||
(**icon).iconMask.baseAddr = NULL ;
|
(**icon).iconMask.baseAddr = NULL ;
|
||||||
(**icon).iconBMap.baseAddr = NULL ;
|
(**icon).iconBMap.baseAddr = NULL ;
|
||||||
(**icon).iconPMap.baseAddr = NULL ;
|
(**icon).iconPMap.baseAddr = NULL ;
|
||||||
HUnlock((Handle)icon) ;
|
HUnlock((Handle)icon) ;
|
||||||
SetGWorld(saveWorld,saveHandle);
|
SetGWorld(saveWorld,saveHandle);
|
||||||
|
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
|
PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
|
||||||
@@ -279,10 +278,10 @@ PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
|
|||||||
|
|
||||||
LockPixels( GetGWorldPixMap( wp ) ) ;
|
LockPixels( GetGWorldPixMap( wp ) ) ;
|
||||||
CopyBits(GetPortBitMapForCopyBits(wp),
|
CopyBits(GetPortBitMapForCopyBits(wp),
|
||||||
GetPortBitMapForCopyBits(wp),
|
GetPortBitMapForCopyBits(wp),
|
||||||
&portRect,
|
&portRect,
|
||||||
&portRect,
|
&portRect,
|
||||||
srcCopy,clipRgn);
|
srcCopy,clipRgn);
|
||||||
UnlockPixels( GetGWorldPixMap( wp ) ) ;
|
UnlockPixels( GetGWorldPixMap( wp ) ) ;
|
||||||
ClosePicture();
|
ClosePicture();
|
||||||
}
|
}
|
||||||
@@ -308,37 +307,37 @@ wxBitmapRefData::wxBitmapRefData()
|
|||||||
// TODO move this do a public function of Bitmap Ref
|
// TODO move this do a public function of Bitmap Ref
|
||||||
static void DisposeBitmapRefData(wxBitmapRefData *data)
|
static void DisposeBitmapRefData(wxBitmapRefData *data)
|
||||||
{
|
{
|
||||||
switch (data->m_bitmapType)
|
switch (data->m_bitmapType)
|
||||||
{
|
{
|
||||||
case kMacBitmapTypePict :
|
case kMacBitmapTypePict :
|
||||||
{
|
{
|
||||||
if ( data->m_hPict )
|
if ( data->m_hPict )
|
||||||
{
|
{
|
||||||
KillPicture( data->m_hPict ) ;
|
KillPicture( data->m_hPict ) ;
|
||||||
data->m_hPict = NULL ;
|
data->m_hPict = NULL ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case kMacBitmapTypeGrafWorld :
|
case kMacBitmapTypeGrafWorld :
|
||||||
{
|
{
|
||||||
if ( data->m_hBitmap )
|
if ( data->m_hBitmap )
|
||||||
{
|
{
|
||||||
wxMacDestroyGWorld( data->m_hBitmap ) ;
|
wxMacDestroyGWorld( data->m_hBitmap ) ;
|
||||||
data->m_hBitmap = NULL ;
|
data->m_hBitmap = NULL ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case kMacBitmapTypeIcon :
|
case kMacBitmapTypeIcon :
|
||||||
if ( data->m_hIcon )
|
if ( data->m_hIcon )
|
||||||
{
|
{
|
||||||
DisposeCIcon( data->m_hIcon ) ;
|
DisposeCIcon( data->m_hIcon ) ;
|
||||||
data->m_hIcon = NULL ;
|
data->m_hIcon = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
default :
|
default :
|
||||||
// unkown type ?
|
// unkown type ?
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->m_bitmapMask)
|
if (data->m_bitmapMask)
|
||||||
{
|
{
|
||||||
@@ -381,8 +380,8 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
|
|||||||
M_BITMAPDATA->m_hBitmap = wxMacCreateGWorld( the_width , the_height , no_bits ) ;
|
M_BITMAPDATA->m_hBitmap = wxMacCreateGWorld( the_width , the_height , no_bits ) ;
|
||||||
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
||||||
|
|
||||||
CGrafPtr origPort ;
|
CGrafPtr origPort ;
|
||||||
GDHandle origDevice ;
|
GDHandle origDevice ;
|
||||||
|
|
||||||
GetGWorld( &origPort , &origDevice ) ;
|
GetGWorld( &origPort , &origDevice ) ;
|
||||||
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
|
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
|
||||||
@@ -580,7 +579,7 @@ void wxBitmap::SetHBITMAP(WXHBITMAP bmp)
|
|||||||
|
|
||||||
M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
|
M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
|
||||||
M_BITMAPDATA->m_hBitmap = bmp ;
|
M_BITMAPDATA->m_hBitmap = bmp ;
|
||||||
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type)
|
bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type)
|
||||||
@@ -591,7 +590,7 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type)
|
|||||||
|
|
||||||
if ( handler )
|
if ( handler )
|
||||||
{
|
{
|
||||||
m_refData = new wxBitmapRefData;
|
m_refData = new wxBitmapRefData;
|
||||||
|
|
||||||
return handler->LoadFile(this, filename, type, -1, -1);
|
return handler->LoadFile(this, filename, type, -1, -1);
|
||||||
}
|
}
|
||||||
@@ -1029,11 +1028,11 @@ wxMask::wxMask(const wxBitmap& bitmap)
|
|||||||
|
|
||||||
wxMask::~wxMask()
|
wxMask::~wxMask()
|
||||||
{
|
{
|
||||||
if ( m_maskBitmap )
|
if ( m_maskBitmap )
|
||||||
{
|
{
|
||||||
wxMacDestroyGWorld( m_maskBitmap ) ;
|
wxMacDestroyGWorld( m_maskBitmap ) ;
|
||||||
m_maskBitmap = NULL ;
|
m_maskBitmap = NULL ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a mask from a mono bitmap (copies the bitmap).
|
// Create a mask from a mono bitmap (copies the bitmap).
|
||||||
@@ -1080,52 +1079,52 @@ bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
|
|||||||
// the transparent area
|
// the transparent area
|
||||||
bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
||||||
{
|
{
|
||||||
if ( m_maskBitmap )
|
if ( m_maskBitmap )
|
||||||
{
|
{
|
||||||
wxMacDestroyGWorld( m_maskBitmap ) ;
|
wxMacDestroyGWorld( m_maskBitmap ) ;
|
||||||
m_maskBitmap = NULL ;
|
m_maskBitmap = NULL ;
|
||||||
}
|
}
|
||||||
wxCHECK_MSG( bitmap.GetBitmapType() == kMacBitmapTypeGrafWorld, false,
|
wxCHECK_MSG( bitmap.GetBitmapType() == kMacBitmapTypeGrafWorld, false,
|
||||||
wxT("Cannot create mask from this bitmap type (TODO)"));
|
wxT("Cannot create mask from this bitmap type (TODO)"));
|
||||||
// other types would require a temporary bitmap. not yet implemented
|
// other types would require a temporary bitmap. not yet implemented
|
||||||
|
|
||||||
wxCHECK_MSG( bitmap.Ok(), false, wxT("Illigal bitmap"));
|
wxCHECK_MSG( bitmap.Ok(), false, wxT("Illigal bitmap"));
|
||||||
|
|
||||||
m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 );
|
m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 );
|
||||||
LockPixels( GetGWorldPixMap( m_maskBitmap ) );
|
LockPixels( GetGWorldPixMap( m_maskBitmap ) );
|
||||||
LockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) );
|
LockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) );
|
||||||
RGBColor maskColor = colour.GetPixel();
|
RGBColor maskColor = colour.GetPixel();
|
||||||
|
|
||||||
// this is not very efficient, but I can't think
|
// this is not very efficient, but I can't think
|
||||||
// of a better way of doing it
|
// of a better way of doing it
|
||||||
CGrafPtr origPort ;
|
CGrafPtr origPort ;
|
||||||
GDHandle origDevice ;
|
GDHandle origDevice ;
|
||||||
RGBColor col;
|
RGBColor col;
|
||||||
RGBColor colors[2] = {
|
RGBColor colors[2] = {
|
||||||
{ 0xFFFF, 0xFFFF, 0xFFFF },
|
{ 0xFFFF, 0xFFFF, 0xFFFF },
|
||||||
{ 0, 0, 0 }};
|
{ 0, 0, 0 }};
|
||||||
|
|
||||||
GetGWorld( &origPort , &origDevice ) ;
|
GetGWorld( &origPort , &origDevice ) ;
|
||||||
for (int w = 0; w < bitmap.GetWidth(); w++)
|
for (int w = 0; w < bitmap.GetWidth(); w++)
|
||||||
{
|
{
|
||||||
for (int h = 0; h < bitmap.GetHeight(); h++)
|
for (int h = 0; h < bitmap.GetHeight(); h++)
|
||||||
{
|
{
|
||||||
SetGWorld( bitmap.GetHBITMAP(), NULL ) ;
|
SetGWorld( bitmap.GetHBITMAP(), NULL ) ;
|
||||||
GetCPixel( w , h , &col ) ;
|
GetCPixel( w , h , &col ) ;
|
||||||
SetGWorld( m_maskBitmap , NULL ) ;
|
SetGWorld( m_maskBitmap , NULL ) ;
|
||||||
if (col.red == maskColor.red && col.green == maskColor.green && col.blue == maskColor.blue)
|
if (col.red == maskColor.red && col.green == maskColor.green && col.blue == maskColor.blue)
|
||||||
{
|
{
|
||||||
SetCPixel( w , h , &colors[0] ) ;
|
SetCPixel( w , h , &colors[0] ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetCPixel( w , h , &colors[1] ) ;
|
SetCPixel( w , h , &colors[1] ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
|
UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
|
||||||
UnlockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) ) ;
|
UnlockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) ) ;
|
||||||
SetGWorld( origPort , origDevice ) ;
|
SetGWorld( origPort , origDevice ) ;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1194,35 +1193,35 @@ IMPLEMENT_DYNAMIC_CLASS(wxPICTResourceHandler, wxBitmapHandler)
|
|||||||
bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||||
int desiredWidth, int desiredHeight)
|
int desiredWidth, int desiredHeight)
|
||||||
{
|
{
|
||||||
Str255 theName ;
|
Str255 theName ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) theName , name ) ;
|
c2pstrcpy( (StringPtr) theName , name ) ;
|
||||||
#else
|
#else
|
||||||
strcpy( (char *) theName , name ) ;
|
strcpy( (char *) theName , name ) ;
|
||||||
c2pstr( (char *)theName ) ;
|
c2pstr( (char *)theName ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ;
|
PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ;
|
||||||
if ( thePict )
|
if ( thePict )
|
||||||
{
|
{
|
||||||
PictInfo theInfo ;
|
PictInfo theInfo ;
|
||||||
|
|
||||||
GetPictInfo( thePict , &theInfo , 0 , 0 , systemMethod , 0 ) ;
|
GetPictInfo( thePict , &theInfo , 0 , 0 , systemMethod , 0 ) ;
|
||||||
DetachResource( (Handle) thePict ) ;
|
DetachResource( (Handle) thePict ) ;
|
||||||
M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypePict ;
|
M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypePict ;
|
||||||
M_BITMAPHANDLERDATA->m_hPict = thePict ;
|
M_BITMAPHANDLERDATA->m_hPict = thePict ;
|
||||||
M_BITMAPHANDLERDATA->m_width = theInfo.sourceRect.right - theInfo.sourceRect.left ;
|
M_BITMAPHANDLERDATA->m_width = theInfo.sourceRect.right - theInfo.sourceRect.left ;
|
||||||
M_BITMAPHANDLERDATA->m_height = theInfo.sourceRect.bottom - theInfo.sourceRect.top ;
|
M_BITMAPHANDLERDATA->m_height = theInfo.sourceRect.bottom - theInfo.sourceRect.top ;
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_depth = theInfo.depth ;
|
M_BITMAPHANDLERDATA->m_depth = theInfo.depth ;
|
||||||
M_BITMAPHANDLERDATA->m_ok = true ;
|
M_BITMAPHANDLERDATA->m_ok = true ;
|
||||||
M_BITMAPHANDLERDATA->m_numColors = theInfo.uniqueColors ;
|
M_BITMAPHANDLERDATA->m_numColors = theInfo.uniqueColors ;
|
||||||
// M_BITMAPHANDLERDATA->m_bitmapPalette;
|
// M_BITMAPHANDLERDATA->m_bitmapPalette;
|
||||||
// M_BITMAPHANDLERDATA->m_quality;
|
// M_BITMAPHANDLERDATA->m_quality;
|
||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::InitStandardHandlers()
|
void wxBitmap::InitStandardHandlers()
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "bitmapbase.h"
|
|
||||||
#pragma implementation "bitmap.h"
|
#pragma implementation "bitmap.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -36,75 +35,75 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject )
|
|||||||
|
|
||||||
CTabHandle wxMacCreateColorTable( int numColors )
|
CTabHandle wxMacCreateColorTable( int numColors )
|
||||||
{
|
{
|
||||||
CTabHandle newColors; /* Handle to the new color table */
|
CTabHandle newColors; /* Handle to the new color table */
|
||||||
|
|
||||||
/* Allocate memory for the color table */
|
/* Allocate memory for the color table */
|
||||||
newColors = (CTabHandle)NewHandleClear( sizeof (ColorTable) +
|
newColors = (CTabHandle)NewHandleClear( sizeof (ColorTable) +
|
||||||
sizeof (ColorSpec) * (numColors - 1) );
|
sizeof (ColorSpec) * (numColors - 1) );
|
||||||
if (newColors != nil)
|
if (newColors != nil)
|
||||||
{
|
{
|
||||||
/* Initialize the fields */
|
/* Initialize the fields */
|
||||||
(**newColors).ctSeed = GetCTSeed();
|
(**newColors).ctSeed = GetCTSeed();
|
||||||
(**newColors).ctFlags = 0;
|
(**newColors).ctFlags = 0;
|
||||||
(**newColors).ctSize = numColors - 1;
|
(**newColors).ctSize = numColors - 1;
|
||||||
/* Initialize the table of colors */
|
/* Initialize the table of colors */
|
||||||
}
|
}
|
||||||
return newColors ;
|
return newColors ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacDestroyColorTable( CTabHandle colors )
|
void wxMacDestroyColorTable( CTabHandle colors )
|
||||||
{
|
{
|
||||||
DisposeHandle( (Handle) colors ) ;
|
DisposeHandle( (Handle) colors ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue )
|
void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue )
|
||||||
{
|
{
|
||||||
(**newColors).ctTable[index].value = index;
|
(**newColors).ctTable[index].value = index;
|
||||||
(**newColors).ctTable[index].rgb.red = 0 ;// someRedValue;
|
(**newColors).ctTable[index].rgb.red = 0 ;// someRedValue;
|
||||||
(**newColors).ctTable[index].rgb.green = 0 ; // someGreenValue;
|
(**newColors).ctTable[index].rgb.green = 0 ; // someGreenValue;
|
||||||
(**newColors).ctTable[index].rgb.blue = 0 ; // someBlueValue;
|
(**newColors).ctTable[index].rgb.blue = 0 ; // someBlueValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GWorldPtr wxMacCreateGWorld( int width , int height , int depth )
|
GWorldPtr wxMacCreateGWorld( int width , int height , int depth )
|
||||||
{
|
{
|
||||||
OSErr err = noErr ;
|
OSErr err = noErr ;
|
||||||
GWorldPtr port ;
|
GWorldPtr port ;
|
||||||
Rect rect = { 0 , 0 , height , width } ;
|
Rect rect = { 0 , 0 , height , width } ;
|
||||||
|
|
||||||
if ( depth < 0 )
|
if ( depth < 0 )
|
||||||
{
|
{
|
||||||
depth = wxDisplayDepth() ;
|
depth = wxDisplayDepth() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = NewGWorld( &port , depth , &rect , NULL , NULL , 0 ) ;
|
err = NewGWorld( &port , depth , &rect , NULL , NULL , 0 ) ;
|
||||||
if ( err == noErr )
|
if ( err == noErr )
|
||||||
{
|
{
|
||||||
return port ;
|
return port ;
|
||||||
}
|
}
|
||||||
return NULL ;
|
return NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacDestroyGWorld( GWorldPtr gw )
|
void wxMacDestroyGWorld( GWorldPtr gw )
|
||||||
{
|
{
|
||||||
if ( gw )
|
if ( gw )
|
||||||
DisposeGWorld( gw ) ;
|
DisposeGWorld( gw ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define kDefaultRes 0x00480000 /* Default resolution is 72 DPI; Fixed type */
|
#define kDefaultRes 0x00480000 /* Default resolution is 72 DPI; Fixed type */
|
||||||
|
|
||||||
OSErr SetupCIconHandlePixMap( CIconHandle icon , short depth , Rect *bounds , CTabHandle colors )
|
OSErr SetupCIconHandlePixMap( CIconHandle icon , short depth , Rect *bounds , CTabHandle colors )
|
||||||
{
|
{
|
||||||
CTabHandle newColors; /* Color table used for the off-screen PixMap */
|
CTabHandle newColors; /* Color table used for the off-screen PixMap */
|
||||||
Ptr offBaseAddr; /* Pointer to the off-screen pixel image */
|
Ptr offBaseAddr; /* Pointer to the off-screen pixel image */
|
||||||
OSErr error; /* Returns error code */
|
OSErr error; /* Returns error code */
|
||||||
short bytesPerRow; /* Number of bytes per row in the PixMap */
|
short bytesPerRow; /* Number of bytes per row in the PixMap */
|
||||||
|
|
||||||
|
|
||||||
error = noErr;
|
error = noErr;
|
||||||
newColors = nil;
|
newColors = nil;
|
||||||
offBaseAddr = nil;
|
offBaseAddr = nil;
|
||||||
|
|
||||||
bytesPerRow = ((depth * (bounds->right - bounds->left) + 31) / 32) * 4;
|
bytesPerRow = ((depth * (bounds->right - bounds->left) + 31) / 32) * 4;
|
||||||
|
|
||||||
/* Clone the clut if indexed color; allocate a dummy clut if direct color*/
|
/* Clone the clut if indexed color; allocate a dummy clut if direct color*/
|
||||||
if (depth <= 8)
|
if (depth <= 8)
|
||||||
@@ -180,15 +179,15 @@ OSErr SetupCIconHandlePixMap( CIconHandle icon , short depth , Rect *bounds , C
|
|||||||
|
|
||||||
CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize )
|
CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize )
|
||||||
{
|
{
|
||||||
GWorldPtr saveWorld;
|
GWorldPtr saveWorld;
|
||||||
GDHandle saveHandle;
|
GDHandle saveHandle;
|
||||||
|
|
||||||
GetGWorld(&saveWorld,&saveHandle); // save Graphics env state
|
GetGWorld(&saveWorld,&saveHandle); // save Graphics env state
|
||||||
SetGWorld(image,nil);
|
SetGWorld(image,nil);
|
||||||
|
|
||||||
Rect frame = { 0 , 0 , iconSize , iconSize } ;
|
Rect frame = { 0 , 0 , iconSize , iconSize } ;
|
||||||
Rect imageBounds = frame ;
|
Rect imageBounds = frame ;
|
||||||
GetPortBounds( image , &imageBounds ) ;
|
GetPortBounds( image , &imageBounds ) ;
|
||||||
|
|
||||||
int bwSize = iconSize / 8 * iconSize ;
|
int bwSize = iconSize / 8 * iconSize ;
|
||||||
CIconHandle icon = (CIconHandle) NewHandleClear( sizeof ( CIcon ) + 2 * bwSize) ;
|
CIconHandle icon = (CIconHandle) NewHandleClear( sizeof ( CIcon ) + 2 * bwSize) ;
|
||||||
@@ -197,16 +196,16 @@ CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth ,
|
|||||||
HLock( (**icon).iconData ) ;
|
HLock( (**icon).iconData ) ;
|
||||||
(**icon).iconPMap.baseAddr = *(**icon).iconData ;
|
(**icon).iconPMap.baseAddr = *(**icon).iconData ;
|
||||||
|
|
||||||
LockPixels(GetGWorldPixMap(image));
|
LockPixels(GetGWorldPixMap(image));
|
||||||
|
|
||||||
CopyBits(GetPortBitMapForCopyBits(image),
|
CopyBits(GetPortBitMapForCopyBits(image),
|
||||||
(BitMapPtr)&((**icon).iconPMap),
|
(BitMapPtr)&((**icon).iconPMap),
|
||||||
&imageBounds,
|
&imageBounds,
|
||||||
&imageBounds,
|
&imageBounds,
|
||||||
srcCopy | ditherCopy, nil);
|
srcCopy | ditherCopy, nil);
|
||||||
|
|
||||||
|
|
||||||
UnlockPixels(GetGWorldPixMap(image));
|
UnlockPixels(GetGWorldPixMap(image));
|
||||||
HUnlock( (**icon).iconData ) ;
|
HUnlock( (**icon).iconData ) ;
|
||||||
|
|
||||||
(**icon).iconMask.rowBytes = iconSize / 8 ;
|
(**icon).iconMask.rowBytes = iconSize / 8 ;
|
||||||
@@ -228,21 +227,21 @@ CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth ,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LockPixels(GetGWorldPixMap(image));
|
LockPixels(GetGWorldPixMap(image));
|
||||||
CopyBits(GetPortBitMapForCopyBits(image) ,
|
CopyBits(GetPortBitMapForCopyBits(image) ,
|
||||||
&(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconBMap , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
||||||
CopyBits(GetPortBitMapForCopyBits(image) ,
|
CopyBits(GetPortBitMapForCopyBits(image) ,
|
||||||
&(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
&(**icon).iconMask , &imageBounds , &imageBounds, srcCopy , nil ) ;
|
||||||
UnlockPixels(GetGWorldPixMap(image));
|
UnlockPixels(GetGWorldPixMap(image));
|
||||||
}
|
}
|
||||||
|
|
||||||
(**icon).iconMask.baseAddr = NULL ;
|
(**icon).iconMask.baseAddr = NULL ;
|
||||||
(**icon).iconBMap.baseAddr = NULL ;
|
(**icon).iconBMap.baseAddr = NULL ;
|
||||||
(**icon).iconPMap.baseAddr = NULL ;
|
(**icon).iconPMap.baseAddr = NULL ;
|
||||||
HUnlock((Handle)icon) ;
|
HUnlock((Handle)icon) ;
|
||||||
SetGWorld(saveWorld,saveHandle);
|
SetGWorld(saveWorld,saveHandle);
|
||||||
|
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
|
PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
|
||||||
@@ -279,10 +278,10 @@ PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
|
|||||||
|
|
||||||
LockPixels( GetGWorldPixMap( wp ) ) ;
|
LockPixels( GetGWorldPixMap( wp ) ) ;
|
||||||
CopyBits(GetPortBitMapForCopyBits(wp),
|
CopyBits(GetPortBitMapForCopyBits(wp),
|
||||||
GetPortBitMapForCopyBits(wp),
|
GetPortBitMapForCopyBits(wp),
|
||||||
&portRect,
|
&portRect,
|
||||||
&portRect,
|
&portRect,
|
||||||
srcCopy,clipRgn);
|
srcCopy,clipRgn);
|
||||||
UnlockPixels( GetGWorldPixMap( wp ) ) ;
|
UnlockPixels( GetGWorldPixMap( wp ) ) ;
|
||||||
ClosePicture();
|
ClosePicture();
|
||||||
}
|
}
|
||||||
@@ -308,37 +307,37 @@ wxBitmapRefData::wxBitmapRefData()
|
|||||||
// TODO move this do a public function of Bitmap Ref
|
// TODO move this do a public function of Bitmap Ref
|
||||||
static void DisposeBitmapRefData(wxBitmapRefData *data)
|
static void DisposeBitmapRefData(wxBitmapRefData *data)
|
||||||
{
|
{
|
||||||
switch (data->m_bitmapType)
|
switch (data->m_bitmapType)
|
||||||
{
|
{
|
||||||
case kMacBitmapTypePict :
|
case kMacBitmapTypePict :
|
||||||
{
|
{
|
||||||
if ( data->m_hPict )
|
if ( data->m_hPict )
|
||||||
{
|
{
|
||||||
KillPicture( data->m_hPict ) ;
|
KillPicture( data->m_hPict ) ;
|
||||||
data->m_hPict = NULL ;
|
data->m_hPict = NULL ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case kMacBitmapTypeGrafWorld :
|
case kMacBitmapTypeGrafWorld :
|
||||||
{
|
{
|
||||||
if ( data->m_hBitmap )
|
if ( data->m_hBitmap )
|
||||||
{
|
{
|
||||||
wxMacDestroyGWorld( data->m_hBitmap ) ;
|
wxMacDestroyGWorld( data->m_hBitmap ) ;
|
||||||
data->m_hBitmap = NULL ;
|
data->m_hBitmap = NULL ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case kMacBitmapTypeIcon :
|
case kMacBitmapTypeIcon :
|
||||||
if ( data->m_hIcon )
|
if ( data->m_hIcon )
|
||||||
{
|
{
|
||||||
DisposeCIcon( data->m_hIcon ) ;
|
DisposeCIcon( data->m_hIcon ) ;
|
||||||
data->m_hIcon = NULL ;
|
data->m_hIcon = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
default :
|
default :
|
||||||
// unkown type ?
|
// unkown type ?
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->m_bitmapMask)
|
if (data->m_bitmapMask)
|
||||||
{
|
{
|
||||||
@@ -381,8 +380,8 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
|
|||||||
M_BITMAPDATA->m_hBitmap = wxMacCreateGWorld( the_width , the_height , no_bits ) ;
|
M_BITMAPDATA->m_hBitmap = wxMacCreateGWorld( the_width , the_height , no_bits ) ;
|
||||||
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
||||||
|
|
||||||
CGrafPtr origPort ;
|
CGrafPtr origPort ;
|
||||||
GDHandle origDevice ;
|
GDHandle origDevice ;
|
||||||
|
|
||||||
GetGWorld( &origPort , &origDevice ) ;
|
GetGWorld( &origPort , &origDevice ) ;
|
||||||
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
|
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
|
||||||
@@ -580,7 +579,7 @@ void wxBitmap::SetHBITMAP(WXHBITMAP bmp)
|
|||||||
|
|
||||||
M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
|
M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
|
||||||
M_BITMAPDATA->m_hBitmap = bmp ;
|
M_BITMAPDATA->m_hBitmap = bmp ;
|
||||||
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type)
|
bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type)
|
||||||
@@ -591,7 +590,7 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type)
|
|||||||
|
|
||||||
if ( handler )
|
if ( handler )
|
||||||
{
|
{
|
||||||
m_refData = new wxBitmapRefData;
|
m_refData = new wxBitmapRefData;
|
||||||
|
|
||||||
return handler->LoadFile(this, filename, type, -1, -1);
|
return handler->LoadFile(this, filename, type, -1, -1);
|
||||||
}
|
}
|
||||||
@@ -1029,11 +1028,11 @@ wxMask::wxMask(const wxBitmap& bitmap)
|
|||||||
|
|
||||||
wxMask::~wxMask()
|
wxMask::~wxMask()
|
||||||
{
|
{
|
||||||
if ( m_maskBitmap )
|
if ( m_maskBitmap )
|
||||||
{
|
{
|
||||||
wxMacDestroyGWorld( m_maskBitmap ) ;
|
wxMacDestroyGWorld( m_maskBitmap ) ;
|
||||||
m_maskBitmap = NULL ;
|
m_maskBitmap = NULL ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a mask from a mono bitmap (copies the bitmap).
|
// Create a mask from a mono bitmap (copies the bitmap).
|
||||||
@@ -1080,52 +1079,52 @@ bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
|
|||||||
// the transparent area
|
// the transparent area
|
||||||
bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
||||||
{
|
{
|
||||||
if ( m_maskBitmap )
|
if ( m_maskBitmap )
|
||||||
{
|
{
|
||||||
wxMacDestroyGWorld( m_maskBitmap ) ;
|
wxMacDestroyGWorld( m_maskBitmap ) ;
|
||||||
m_maskBitmap = NULL ;
|
m_maskBitmap = NULL ;
|
||||||
}
|
}
|
||||||
wxCHECK_MSG( bitmap.GetBitmapType() == kMacBitmapTypeGrafWorld, false,
|
wxCHECK_MSG( bitmap.GetBitmapType() == kMacBitmapTypeGrafWorld, false,
|
||||||
wxT("Cannot create mask from this bitmap type (TODO)"));
|
wxT("Cannot create mask from this bitmap type (TODO)"));
|
||||||
// other types would require a temporary bitmap. not yet implemented
|
// other types would require a temporary bitmap. not yet implemented
|
||||||
|
|
||||||
wxCHECK_MSG( bitmap.Ok(), false, wxT("Illigal bitmap"));
|
wxCHECK_MSG( bitmap.Ok(), false, wxT("Illigal bitmap"));
|
||||||
|
|
||||||
m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 );
|
m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 );
|
||||||
LockPixels( GetGWorldPixMap( m_maskBitmap ) );
|
LockPixels( GetGWorldPixMap( m_maskBitmap ) );
|
||||||
LockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) );
|
LockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) );
|
||||||
RGBColor maskColor = colour.GetPixel();
|
RGBColor maskColor = colour.GetPixel();
|
||||||
|
|
||||||
// this is not very efficient, but I can't think
|
// this is not very efficient, but I can't think
|
||||||
// of a better way of doing it
|
// of a better way of doing it
|
||||||
CGrafPtr origPort ;
|
CGrafPtr origPort ;
|
||||||
GDHandle origDevice ;
|
GDHandle origDevice ;
|
||||||
RGBColor col;
|
RGBColor col;
|
||||||
RGBColor colors[2] = {
|
RGBColor colors[2] = {
|
||||||
{ 0xFFFF, 0xFFFF, 0xFFFF },
|
{ 0xFFFF, 0xFFFF, 0xFFFF },
|
||||||
{ 0, 0, 0 }};
|
{ 0, 0, 0 }};
|
||||||
|
|
||||||
GetGWorld( &origPort , &origDevice ) ;
|
GetGWorld( &origPort , &origDevice ) ;
|
||||||
for (int w = 0; w < bitmap.GetWidth(); w++)
|
for (int w = 0; w < bitmap.GetWidth(); w++)
|
||||||
{
|
{
|
||||||
for (int h = 0; h < bitmap.GetHeight(); h++)
|
for (int h = 0; h < bitmap.GetHeight(); h++)
|
||||||
{
|
{
|
||||||
SetGWorld( bitmap.GetHBITMAP(), NULL ) ;
|
SetGWorld( bitmap.GetHBITMAP(), NULL ) ;
|
||||||
GetCPixel( w , h , &col ) ;
|
GetCPixel( w , h , &col ) ;
|
||||||
SetGWorld( m_maskBitmap , NULL ) ;
|
SetGWorld( m_maskBitmap , NULL ) ;
|
||||||
if (col.red == maskColor.red && col.green == maskColor.green && col.blue == maskColor.blue)
|
if (col.red == maskColor.red && col.green == maskColor.green && col.blue == maskColor.blue)
|
||||||
{
|
{
|
||||||
SetCPixel( w , h , &colors[0] ) ;
|
SetCPixel( w , h , &colors[0] ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetCPixel( w , h , &colors[1] ) ;
|
SetCPixel( w , h , &colors[1] ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
|
UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
|
||||||
UnlockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) ) ;
|
UnlockPixels( GetGWorldPixMap( bitmap.GetHBITMAP() ) ) ;
|
||||||
SetGWorld( origPort , origDevice ) ;
|
SetGWorld( origPort , origDevice ) ;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1194,35 +1193,35 @@ IMPLEMENT_DYNAMIC_CLASS(wxPICTResourceHandler, wxBitmapHandler)
|
|||||||
bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||||
int desiredWidth, int desiredHeight)
|
int desiredWidth, int desiredHeight)
|
||||||
{
|
{
|
||||||
Str255 theName ;
|
Str255 theName ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy( (StringPtr) theName , name ) ;
|
c2pstrcpy( (StringPtr) theName , name ) ;
|
||||||
#else
|
#else
|
||||||
strcpy( (char *) theName , name ) ;
|
strcpy( (char *) theName , name ) ;
|
||||||
c2pstr( (char *)theName ) ;
|
c2pstr( (char *)theName ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ;
|
PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ;
|
||||||
if ( thePict )
|
if ( thePict )
|
||||||
{
|
{
|
||||||
PictInfo theInfo ;
|
PictInfo theInfo ;
|
||||||
|
|
||||||
GetPictInfo( thePict , &theInfo , 0 , 0 , systemMethod , 0 ) ;
|
GetPictInfo( thePict , &theInfo , 0 , 0 , systemMethod , 0 ) ;
|
||||||
DetachResource( (Handle) thePict ) ;
|
DetachResource( (Handle) thePict ) ;
|
||||||
M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypePict ;
|
M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypePict ;
|
||||||
M_BITMAPHANDLERDATA->m_hPict = thePict ;
|
M_BITMAPHANDLERDATA->m_hPict = thePict ;
|
||||||
M_BITMAPHANDLERDATA->m_width = theInfo.sourceRect.right - theInfo.sourceRect.left ;
|
M_BITMAPHANDLERDATA->m_width = theInfo.sourceRect.right - theInfo.sourceRect.left ;
|
||||||
M_BITMAPHANDLERDATA->m_height = theInfo.sourceRect.bottom - theInfo.sourceRect.top ;
|
M_BITMAPHANDLERDATA->m_height = theInfo.sourceRect.bottom - theInfo.sourceRect.top ;
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_depth = theInfo.depth ;
|
M_BITMAPHANDLERDATA->m_depth = theInfo.depth ;
|
||||||
M_BITMAPHANDLERDATA->m_ok = true ;
|
M_BITMAPHANDLERDATA->m_ok = true ;
|
||||||
M_BITMAPHANDLERDATA->m_numColors = theInfo.uniqueColors ;
|
M_BITMAPHANDLERDATA->m_numColors = theInfo.uniqueColors ;
|
||||||
// M_BITMAPHANDLERDATA->m_bitmapPalette;
|
// M_BITMAPHANDLERDATA->m_bitmapPalette;
|
||||||
// M_BITMAPHANDLERDATA->m_quality;
|
// M_BITMAPHANDLERDATA->m_quality;
|
||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::InitStandardHandlers()
|
void wxBitmap::InitStandardHandlers()
|
||||||
|
Reference in New Issue
Block a user