mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
improve bitmap generation: only foreground needs to change; background
can always be transparent.
This commit is contained in:
parent
cd85406c01
commit
0fa5f5fcd5
1 changed files with 7 additions and 11 deletions
|
@ -755,24 +755,20 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
{
|
{
|
||||||
int foreColor, backColor;
|
int foreColor, backColor;
|
||||||
foreColor = pending? WHITE : m_playerColors[owner];
|
foreColor = pending? WHITE : m_playerColors[owner];
|
||||||
backColor = pending? BLACK : m_otherColors[CommonPrefs.COLOR_TILE_BACK];
|
|
||||||
|
|
||||||
int width = base.getWidth();
|
int width = base.getWidth();
|
||||||
int height = base.getHeight();
|
int height = base.getHeight();
|
||||||
IntBuffer intBuffer = IntBuffer.allocate( width * height );
|
IntBuffer intBuffer = IntBuffer.allocate( width * height );
|
||||||
base.copyPixelsToBuffer( intBuffer );
|
base.copyPixelsToBuffer( intBuffer );
|
||||||
|
|
||||||
final int[] oldInts = intBuffer.array();
|
final int[] oldInts = intBuffer.array();
|
||||||
int[] newInts = new int[oldInts.length];
|
int len = oldInts.length;
|
||||||
for ( int ii = 0; ii < oldInts.length; ++ii ) {
|
int[] newInts = new int[len];
|
||||||
int pixel = oldInts[ii];
|
System.arraycopy( oldInts, 0, newInts, 0, len );
|
||||||
if ( pixel == 0xFF000000 ) {
|
for ( int ii = 0; ii < len; ++ii ) {
|
||||||
pixel = foreColor;
|
if ( oldInts[ii] == 0xFF000000 ) {
|
||||||
} else {
|
newInts[ii] = foreColor;
|
||||||
// Note: these pixels though I set them to 00FFFFFF
|
|
||||||
// test == 0 here. Nonetheless, replacing them works.
|
|
||||||
pixel = backColor;
|
|
||||||
}
|
}
|
||||||
newInts[ii] = pixel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap bitmap = Bitmap.createBitmap( newInts, width, height,
|
Bitmap bitmap = Bitmap.createBitmap( newInts, width, height,
|
||||||
|
|
Loading…
Reference in a new issue