Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/billforsternz/tarras…
Browse files Browse the repository at this point in the history
…ch-chess-gui into development
  • Loading branch information
billforsternz committed Dec 22, 2015
2 parents 7f9f223 + 4fe7ca1 commit 8f8f0c3
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 162 deletions.
108 changes: 40 additions & 68 deletions src/t3/BoardSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,28 +179,18 @@ BoardSetup::BoardSetup( wxBitmap *bitmap, wxWindow *parent, int XBORDER, int YBO
(unsigned long)info.bmHeight );

#else
#ifdef THC_MAC
wxAlphaPixelData bmdata(*bitmap);
wxNativePixelData bmdata2(*bitmap);
if( bmdata )
{
height = bmdata.GetHeight();
width = bmdata.GetWidth();
wxPoint x = bmdata.GetOrigin();
wxSize z = bmdata.GetSize();
int row_stride = bmdata.GetRowStride();
cprintf( "Alpha x=%d,%d z=%d,%d, height=%d, width=%d, row_stride=%d\n",x.x,x.y,z.x,z.y,height,width,row_stride);
width_bytes = row_stride;
}
else
{
height = bmdata2.GetHeight();
width = bmdata2.GetWidth();
wxPoint x = bmdata2.GetOrigin();
wxSize z = bmdata2.GetSize();
int row_stride = bmdata2.GetRowStride();
cprintf( "Native x=%d,%d z=%d,%d, height=%d, width=%d, row_stride=%d\n",x.x,x.y,z.x,z.y,height,width,row_stride);
width_bytes = row_stride;
}
#else
wxNativePixelData bmdata(*bitmap);
#endif
height = bmdata.GetHeight();
width = bmdata.GetWidth();
wxPoint x = bmdata.GetOrigin();
wxSize z = bmdata.GetSize();
int row_stride = bmdata.GetRowStride();
cprintf( "x=%d,%d z=%d,%d, height=%d, width=%d, row_stride=%d\n",x.x,x.y,z.x,z.y,height,width,row_stride);
width_bytes = row_stride;
density = width_bytes/width;
#endif

Expand All @@ -219,30 +209,21 @@ BoardSetup::BoardSetup( wxBitmap *bitmap, wxWindow *parent, int XBORDER, int YBO
//bitmap->GetBitmapBits( width_bytes*height, buf_board ); //@@
::GetBitmapBits((HBITMAP)(bitmap->GetHBITMAP()), width_bytes*height, buf_board );
#else
if( bmdata )
{
wxAlphaPixelData::Iterator p(bmdata);
byte *dst = buf_board;
for( int i=0; i<height*width; i++ )
{
*dst++ = p.Alpha();
*dst++ = p.Red();
*dst++ = p.Green();
*dst++ = p.Blue();
p++;
}
}
else
#ifdef THC_MAC
wxAlphaPixelData::Iterator p(bmdata);
#else
wxNativePixelData::Iterator p(bmdata);
#endif
byte *dst = buf_board;
for( int i=0; i<height*width; i++ )
{
wxNativePixelData::Iterator p(bmdata2);
byte *dst = buf_board;
for( int i=0; i<height*width; i++ )
{
*dst++ = p.Red();
*dst++ = p.Green();
*dst++ = p.Blue();
p++;
}
#ifdef THC_MAC
*dst++ = p.Alpha();
#endif
*dst++ = p.Red();
*dst++ = p.Green();
*dst++ = p.Blue();
p++;
}
#endif

Expand Down Expand Up @@ -444,32 +425,23 @@ void BoardSetup::SetPosition( const char *position_ascii )
//bitmap->SetBitmapBits( width_bytes*height, buf_board );
/*int ret = */::SetBitmapBits( (HBITMAP)(bitmap->GetHBITMAP()), width_bytes*height, buf_board ); //@@
#else
#ifdef THC_MAC
wxAlphaPixelData bmdata(*bitmap);
wxNativePixelData bmdata2(*bitmap);
if( bmdata )
{
wxAlphaPixelData::Iterator p(bmdata);
byte *src = buf_board;
for( i=0; i<height*width; i++ )
{
p.Alpha() = *src++;
p.Red() = *src++;
p.Green() = *src++;
p.Blue() = *src++;
p++;
}
}
else
wxAlphaPixelData::Iterator p(bmdata);
#else
wxNativePixelData bmdata(*bitmap);
wxNativePixelData::Iterator p(bmdata);
#endif
byte *src = buf_board;
for( i=0; i<height*width; i++ )
{
wxNativePixelData::Iterator p(bmdata2);
byte *src = buf_board;
for( i=0; i<height*width; i++ )
{
p.Red() = *src++;
p.Green() = *src++;
p.Blue() = *src++;
p++;
}
#ifdef THC_MAC
p.Alpha() = *src++;
#endif
p.Red() = *src++;
p.Green() = *src++;
p.Blue() = *src++;
p++;
}
#endif

Expand Down
151 changes: 57 additions & 94 deletions src/t3/GraphicBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,20 @@ GraphicBoard::GraphicBoard
density = info.bmWidthBytes/info.bmWidth;
#else
height = my_chess_bmp.GetHeight();
#ifdef THC_MAC
wxAlphaPixelData bmdata(my_chess_bmp);
wxNativePixelData bmdata2(my_chess_bmp);
if( bmdata )
{
height = bmdata.GetHeight();
width = bmdata.GetWidth();
wxPoint x = bmdata.GetOrigin();
wxSize z = bmdata.GetSize();
int row_stride = bmdata.GetRowStride();
if( row_stride < 0 )
row_stride = 0-row_stride;
cprintf( "Alpha x=%d,%d z=%d,%d, height=%d, width=%d, row_stride=%d\n",x.x,x.y,z.x,z.y,height,width,row_stride);
width_bytes = row_stride;
}
else
{
height = bmdata2.GetHeight();
width = bmdata2.GetWidth();
wxPoint x = bmdata2.GetOrigin();
wxSize z = bmdata2.GetSize();
int row_stride = bmdata2.GetRowStride();
cprintf( "Native x=%d,%d z=%d,%d, height=%d, width=%d, row_stride=%d\n",x.x,x.y,z.x,z.y,height,width,row_stride);
width_bytes = row_stride;
}
#else
wxNativePixelData bmdata(my_chess_bmp);
#endif
height = bmdata.GetHeight();
width = bmdata.GetWidth();
wxPoint x = bmdata.GetOrigin();
wxSize z = bmdata.GetSize();
int row_stride = bmdata.GetRowStride();
if( row_stride < 0 )
row_stride = 0-row_stride;
cprintf( "x=%d,%d z=%d,%d, height=%d, width=%d, row_stride=%d\n",x.x,x.y,z.x,z.y,height,width,row_stride);
width_bytes = row_stride;
if( width )
density = width_bytes/width;
#endif
Expand All @@ -124,30 +114,21 @@ GraphicBoard::GraphicBoard
int ret= ::GetBitmapBits((HBITMAP)(my_chess_bmp.GetHBITMAP()), width_bytes*height, buf_board );
//dbg_printf( "::GetBitmapBits() returns %d\n",ret);
#else
if( bmdata )
{
wxAlphaPixelData::Iterator p(bmdata);
byte *dst = buf_board;
for( int i=0; i<height*width; i++ )
{
*dst++ = p.Alpha();
*dst++ = p.Red();
*dst++ = p.Green();
*dst++ = p.Blue();
p++;
}
}
else
#ifdef THC_MAC
wxAlphaPixelData::Iterator p(bmdata);
#else
wxNativePixelData::Iterator p(bmdata);
#endif
byte *dst = buf_board;
for( int i=0; i<height*width; i++ )
{
wxNativePixelData::Iterator p(bmdata2);
byte *dst = buf_board;
for( int i=0; i<height*width; i++ )
{
*dst++ = p.Red();
*dst++ = p.Green();
*dst++ = p.Blue();
p++;
}
#ifdef THC_MAC
*dst++ = p.Alpha();
#endif
*dst++ = p.Red();
*dst++ = p.Green();
*dst++ = p.Blue();
p++;
}
#endif

Expand Down Expand Up @@ -365,32 +346,23 @@ void GraphicBoard::SetPosition( char *position_ascii )
/*int ret = ::*/SetBitmapBits( (HBITMAP)(my_chess_bmp.GetHBITMAP()), width_bytes*height, buf_board ); //@@
//dbg_printf( "::SetBitmapBits() returns %d\n", ret );
#else
#ifdef THC_MAC
wxAlphaPixelData bmdata(my_chess_bmp);
wxNativePixelData bmdata2(my_chess_bmp);
if( bmdata )
{
wxAlphaPixelData::Iterator p(bmdata);
byte *src = buf_board;
for( int i=0; i<height*width; i++ )
{
p.Alpha() = *src++;
p.Red() = *src++;
p.Green() = *src++;
p.Blue() = *src++;
p++;
}
}
else
wxAlphaPixelData::Iterator p(bmdata);
#else
wxNativePixelData bmdata(my_chess_bmp);
wxNativePixelData::Iterator p(bmdata);
#endif
byte *src = buf_board;
for( int i=0; i<height*width; i++ )
{
wxNativePixelData::Iterator p(bmdata2);
byte *src = buf_board;
for( int i=0; i<height*width; i++ )
{
p.Red() = *src++;
p.Green() = *src++;
p.Blue() = *src++;
p++;
}
#ifdef THC_MAC
p.Alpha() = *src++;
#endif
p.Red() = *src++;
p.Green() = *src++;
p.Blue() = *src++;
p++;
}
#endif

Expand Down Expand Up @@ -737,32 +709,23 @@ void GraphicBoard::SetPositionEx( thc::ChessPosition pos, bool blank_other_squar
/*int ret = ::*/SetBitmapBits( (HBITMAP)(my_chess_bmp.GetHBITMAP()), width_bytes*height, buf_board ); //@@
//dbg_printf( "::SetBitmapBits() returns %d\n", ret );
#else
#ifdef THC_MAC
wxAlphaPixelData bmdata(my_chess_bmp);
wxNativePixelData bmdata2(my_chess_bmp);
if( bmdata )
{
wxAlphaPixelData::Iterator p(bmdata);
byte *src = buf_board;
for( int i=0; i<height*width; i++ )
{
p.Alpha() = *src++;
p.Red() = *src++;
p.Green() = *src++;
p.Blue() = *src++;
p++;
}
}
else
wxAlphaPixelData::Iterator p(bmdata);
#else
wxNativePixelData bmdata(my_chess_bmp);
wxNativePixelData::Iterator p(bmdata);
#endif
byte *src = buf_board;
for( int i=0; i<height*width; i++ )
{
wxNativePixelData::Iterator p(bmdata2);
byte *src = buf_board;
for( int i=0; i<height*width; i++ )
{
p.Red() = *src++;
p.Green() = *src++;
p.Blue() = *src++;
p++;
}
#ifdef THC_MAC
p.Alpha() = *src++;
#endif
p.Red() = *src++;
p.Green() = *src++;
p.Blue() = *src++;
p++;
}
#endif

Expand Down

0 comments on commit 8f8f0c3

Please sign in to comment.