Fix launcher crashing on minimise.

This commit is contained in:
UnknownShadow200 2015-12-15 11:13:39 +11:00
parent d7e3e9d200
commit 00774ae6d2

View File

@ -75,7 +75,7 @@ namespace ClassicalSharp {
} }
void DrawPart( FastBitmap fastBmp, Font font, ref int x, int y, TextPart part ) { void DrawPart( FastBitmap dst, Font font, ref int x, int y, TextPart part ) {
string text = part.Text; string text = part.Text;
FastColour textCol = part.TextColour; FastColour textCol = part.TextColour;
float point = font.Size; float point = font.Size;
@ -92,19 +92,23 @@ namespace ClassicalSharp {
for( int yy = 0; yy < dstHeight; yy++ ) { for( int yy = 0; yy < dstHeight; yy++ ) {
int fontY = srcY + yy * srcHeight / dstHeight; int fontY = srcY + yy * srcHeight / dstHeight;
int* fontRow = fontPixels.GetRowPtr( fontY ); int* fontRow = fontPixels.GetRowPtr( fontY );
int* dstRow = fastBmp.GetRowPtr( y + yy ); int dstY = y + yy;
int xOffset = xMul * ((dstHeight - 1 - yy) / italicSize); if( dstY >= dst.Height ) continue;
int* dstRow = dst.GetRowPtr( dstY );
int xOffset = xMul * ((dstHeight - 1 - yy) / italicSize);
for( int xx = 0; xx < dstWidth; xx++ ) { for( int xx = 0; xx < dstWidth; xx++ ) {
int fontX = srcX + xx * srcWidth / dstWidth; int fontX = srcX + xx * srcWidth / dstWidth;
int pixel = fontRow[fontX]; int pixel = fontRow[fontX];
if( (byte)(pixel >> 24) == 0 ) continue; if( (byte)(pixel >> 24) == 0 ) continue;
int dstX = x + xx + xOffset;
if( dstX >= dst.Width ) continue;
int col = pixel & ~0xFFFFFF; int col = pixel & ~0xFFFFFF;
col |= ((pixel & 0xFF) * textCol.B / 255); col |= ((pixel & 0xFF) * textCol.B / 255);
col |= (((pixel >> 8) & 0xFF) * textCol.G / 255) << 8; col |= (((pixel >> 8) & 0xFF) * textCol.G / 255) << 8;
col |= (((pixel >> 16) & 0xFF) * textCol.R / 255) << 16; col |= (((pixel >> 16) & 0xFF) * textCol.R / 255) << 16;
dstRow[x + xx + xOffset] = col; dstRow[dstX] = col;
} }
} }
x += PtToPx( point, srcWidth + 1 ); x += PtToPx( point, srcWidth + 1 );