19,468
社区成员
发帖
与我相关
我的任务
分享
void DrawCharToTexture(Texture* texture, FT_Bitmap* bitmap, short xOffset, short yOffset)
{
Byte* pTexBuf = texture->GetImageBuf();
short texWidth = texture->GetWidth();
short texHeight= texture->GetHeight();
for (int x=0; x<bitmap->width; x++)
{
for (int y=0; y<bitmap->rows; y++)
{
int X = x + xOffset;
int Y = y + yOffset;
if (X < 0 || Y < 0 || X >= texWidth || Y >= texHeight) continue;
Byte alpha = bitmap->buffer[((bitmap->rows - y - 1) * bitmap->width + x)];
alpha *= mTransparent;
if (0 != alpha)
{
Byte* pPixel = pTexBuf + (Y * texWidth + X) * 4;
pPixel[0] = mColor.x;
pPixel[1] = mColor.y;
pPixel[2] = mColor.z;
pPixel[3] = alpha;
}
}
}
}
// 画文字的调用
short yOffset = texHeight - slot->bitmap_top;