applied correction from Marc Newsam in calculations of linesize

tested with the image sample which now produces expected results


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10018 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Gilles Depeyrot
2001-05-06 18:51:22 +00:00
parent db157a6cf8
commit d2c6d54928
2 changed files with 106 additions and 128 deletions

View File

@@ -276,25 +276,13 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
LockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;
#ifdef __UNIX__
// bits is a word aligned array?? Don't think so
// bits is a char array on MAC OS X however using the benefit of the
// doubt I replaced references to 16 with sizeof(unsigned char)*8
// bits is a char array
unsigned char* linestart = (unsigned char*) bits ;
int linesize = ( the_width / (sizeof(unsigned char) * 8)) ;
if ( the_width % (sizeof(unsigned char) * 8) ) {
linesize += sizeof(unsigned char);
}
#else
// bits is a word aligned array
unsigned char* linestart = (unsigned char*) bits ;
int linesize = ( the_width / 16 ) * 2 ;
if ( the_width % 16 )
{
linesize += 2 ;
}
#endif
RGBColor colors[2] = {
{ 0xFFFF , 0xFFFF , 0xFFFF } ,
@@ -328,9 +316,10 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
wxFAIL_MSG(wxT("multicolor BITMAPs not yet implemented"));
}
if ( wxTheBitmapList )
if ( wxTheBitmapList ) {
wxTheBitmapList->AddBitmap(this);
}
}
wxBitmap::wxBitmap(int w, int h, int d)
{

View File

@@ -276,25 +276,13 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ;
LockPixels( GetGWorldPixMap( M_BITMAPDATA->m_hBitmap ) ) ;
#ifdef __UNIX__
// bits is a word aligned array?? Don't think so
// bits is a char array on MAC OS X however using the benefit of the
// doubt I replaced references to 16 with sizeof(unsigned char)*8
// bits is a char array
unsigned char* linestart = (unsigned char*) bits ;
int linesize = ( the_width / (sizeof(unsigned char) * 8)) ;
if ( the_width % (sizeof(unsigned char) * 8) ) {
linesize += sizeof(unsigned char);
}
#else
// bits is a word aligned array
unsigned char* linestart = (unsigned char*) bits ;
int linesize = ( the_width / 16 ) * 2 ;
if ( the_width % 16 )
{
linesize += 2 ;
}
#endif
RGBColor colors[2] = {
{ 0xFFFF , 0xFFFF , 0xFFFF } ,
@@ -328,9 +316,10 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
wxFAIL_MSG(wxT("multicolor BITMAPs not yet implemented"));
}
if ( wxTheBitmapList )
if ( wxTheBitmapList ) {
wxTheBitmapList->AddBitmap(this);
}
}
wxBitmap::wxBitmap(int w, int h, int d)
{