本文整理汇总了C++中Bitmap::CreateCopy方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitmap::CreateCopy方法的具体用法?C++ Bitmap::CreateCopy怎么用?C++ Bitmap::CreateCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitmap
的用法示例。
在下文中一共展示了Bitmap::CreateCopy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Bitmap
Bitmap *CreateBitmapCopy(Bitmap *src, int color_depth)
{
Bitmap *bitmap = new Bitmap();
if (!bitmap->CreateCopy(src, color_depth))
{
delete bitmap;
bitmap = NULL;
}
return bitmap;
}
示例2: DrawSpriteWithTransparency
void DrawSpriteWithTransparency(Bitmap *ds, Bitmap *sprite, int x, int y, int alpha)
{
if (alpha <= 0)
{
// fully transparent, don't draw it at all
return;
}
int surface_depth = ds->GetColorDepth();
int sprite_depth = sprite->GetColorDepth();
if (sprite_depth < surface_depth
// CHECKME: what is the purpose of this hack and is this still relevant?
#if defined(IOS_VERSION) || defined(ANDROID_VERSION)
|| (ds->GetBPP() < surface_depth && psp_gfx_renderer > 0) // Fix for corrupted speechbox outlines with the OGL driver
#endif
)
{
// If sprite is lower color depth than destination surface, e.g.
// 8-bit sprites drawn on 16/32-bit surfaces.
if (sprite_depth == 8 && surface_depth >= 24)
{
// 256-col sprite -> truecolor background
// this is automatically supported by allegro, no twiddling needed
ds->Blit(sprite, x, y, kBitmap_Transparency);
return;
}
// 256-col sprite -> hi-color background, or
// 16-bit sprite -> 32-bit background
Bitmap hctemp;
hctemp.CreateCopy(sprite, surface_depth);
if (sprite_depth == 8)
{
// only do this for 256-col -> hi-color, cos the Blit call converts
// transparency for 16->32 bit
color_t mask_color = hctemp.GetMaskColor();
for (int scan_y = 0; scan_y < hctemp.GetHeight(); ++scan_y)
{
// we know this must be 1 bpp source and 2 bpp pixel destination
const uint8_t *src_scanline = sprite->GetScanLine(scan_y);
uint16_t *dst_scanline = (uint16_t*)hctemp.GetScanLineForWriting(scan_y);
for (int scan_x = 0; scan_x < hctemp.GetWidth(); ++scan_x)
{
if (src_scanline[scan_x] == 0)
{
dst_scanline[scan_x] = mask_color;
}
}
}
}
if (alpha < 0xFF)
{
set_trans_blender(0, 0, 0, alpha);
ds->TransBlendBlt(&hctemp, x, y);
}
else
{
ds->Blit(&hctemp, x, y, kBitmap_Transparency);
}
}
else
{
if (alpha < 0xFF && surface_depth > 8 && sprite_depth > 8)
{
set_trans_blender(0, 0, 0, alpha);
ds->TransBlendBlt(sprite, x, y);
}
else
{
ds->Blit(sprite, x, y, kBitmap_Transparency);
}
}
}