本文整理汇总了C++中Bitmap::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitmap::Clear方法的具体用法?C++ Bitmap::Clear怎么用?C++ Bitmap::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitmap
的用法示例。
在下文中一共展示了Bitmap::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Disabled
void MAS::HyperText::Draw(Bitmap &canvas) {
// get the button state
int state = Disabled() ? 2 : ((Selected() || (Flags() & D_PRESSED)) ? 1 : (HasFocus() ? 3 : 0));
// get the button colors and font
Color fg = GetFontColor(state);
Color bg = GetShadowColor(state);
Font f = GetFont(state);
Color textMode = GetTextMode();
canvas.Clear(textMode);
switch (state) {
case 0:
case 2:
f.GUITextoutEx(canvas, text, 1, 1, fg, bg, textMode, 0);
canvas.Hline(1, h()-3, w()-2, fg);
break;
case 1:
f.GUITextoutEx(canvas, text, 2, 2, fg, bg, textMode, 0);
canvas.DrawDottedRect(1, 1, w()-1, h()-1, skin->c_font);
canvas.Hline(1, h()-2, w()-2, fg);
break;
case 3:
f.GUITextoutEx(canvas, text, 1, 1, fg, bg, textMode, 0);
canvas.DrawDottedRect(0, 0, w()-2, h()-2, skin->c_font);
canvas.Hline(1, h()-3, w()-2, fg);
break;
};
}
示例2: rect
void
GUI::_DisplayStringCommon(const std::string& text,
uint16 x, uint16 y, bool centerString, uint32 time)
{
static uint32 sCurrentId = 0;
const Font* font = FontRoster::GetFont("TOOLFONT");
uint16 height;
uint16 stringWidth = font->StringWidth(text, &height);
Bitmap* bitmap = new Bitmap(stringWidth, height, 8);
bitmap->Clear(font->TransparentIndex());
//bitmap->SetColorKey(font->TransparentIndex());
// Pre-render the string to a bitmap
GFX::rect rect(0, 0, bitmap->Width(), bitmap->Height());
font->RenderString(text, 0, bitmap, rect);
// Set the position where to blit the bitmap
rect.x = x;
rect.y = y;
if (centerString) {
rect.x -= stringWidth / 2;
}
string_entry entry = { text, bitmap, rect, sCurrentId};
fTooltipList.push_back(entry);
long id = sCurrentId++;
Timer::AddOneShotTimer((uint32)time, DeleteStringEntry, (void*)id);
}
示例3: Draw
void PlayArea::Draw(Bitmap &canvas) {
canvas.Clear(Color::black);
int x = 0;
int y = PIECESIZE*PLAYHEIGHT;
MyColor c;
for (int j=0; j<PLAYHEIGHT; j++) {
x = 0;
y -= PIECESIZE;
for (int i=0; i<PLAYWIDTH; i++) {
//canvas.Rectangle(x, y, x+PIECESIZE, y+PIECESIZE, Color::darkgray);
c = GetTile(i,j);
if (c.c1) {
//canvas.Rectfill(x, y, x+PIECESIZE, y+PIECESIZE, c);
canvas.Rectfill( x, y, x+PIECESIZE-1, y+PIECESIZE-1, c.c1);
canvas.Rectangle(x+1, y+1, x+PIECESIZE-2, y+PIECESIZE-2, c.c2);
canvas.Rectangle(x+3, y+3, x+PIECESIZE-4, y+PIECESIZE-4, c.c3);
}
x += PIECESIZE;
}
}
if (curPiece) {
curPiece->Draw(canvas);
}
}
示例4: tmp
// a simple function that applies a blur effect on a bitmap
// - Bitmap &bmp: the input bitmap
// - int radius: blur radius
void MAS::Cursor::Blur(Bitmap &bmp, int radius) {
int x, y;
int i, j;
int r,g,b;
int div = (2*radius+1)*(2*radius+1);
Bitmap tmp2(bmp.w(), bmp.h(), Bitmap::MEMORY);
tmp2.Clear(Color::transparent);
bmp.Blit(tmp2, 0, 0, 0, 0, bmp.w(), bmp.h());
Bitmap tmp(Size(bmp.w() + 2*radius, bmp.h() + 2*radius), Bitmap::MEMORY);
tmp.Clear(Color::black);
bmp.Blit(tmp, Point(0,0), Point(radius, radius), bmp.size());
for (y=radius; y<tmp.h()-radius; y++) {
for (x=radius; x<tmp.w()-radius; x++) {
r = g = b = 0;
for (j=-radius; j<=radius; j++) {
for (i=-radius; i<=radius; i++) {
Color col = tmp.Getpixel(Point(x+i, y+j));
r += col.r();
g += col.g();
b += col.b();
}
}
tmp2.Putpixel(Point(x-radius, y-radius), Color(r/div, g/div, b/div));
}
}
bmp.Clear();
tmp2.Blit(bmp, 0, 0, 0, 0, bmp.w(), bmp.h());
}
示例5:
Z_DEFINE_TEST_CASE(Bitmap, tester, clear)
{
Bitmap bitmap;
bitmap.Set(100);
Z_EXPECT_TRUE(bitmap.Test(100));
bitmap.Clear(100);
Z_EXPECT_FALSE(bitmap.Test(100));
}
示例6: MAX
void MAS::Image::Draw(Bitmap &canvas) {
if (!bmp && bitmap < 0) {
return;
}
Bitmap bmp2 = bmp ? bmp : skin->GetBitmap(bitmap);
if (!bmp2) {
return;
}
int xx = MAX((w() - bmp2.w())/2, 0);
int yy = MAX((h() - bmp2.h())/2, 0);
if (bg)
canvas.Clear(bg);
bmp2.Blit(canvas, 0, 0, xx, yy, w(), h());
}
示例7: CreateBlankImage
// Create blank (black) images used to repaint borders around game frame
void CreateBlankImage(int coldepth)
{
// this is the first time that we try to use the graphics driver,
// so it's the most likey place for a crash
try
{
Bitmap *blank = BitmapHelper::CreateBitmap(16, 16, coldepth);
blank = ReplaceBitmapWithSupportedFormat(blank);
blank->Clear();
blankImage = gfxDriver->CreateDDBFromBitmap(blank, false, true);
blankSidebarImage = gfxDriver->CreateDDBFromBitmap(blank, false, true);
delete blank;
}
catch (Ali3DException gfxException)
{
quit((char*)gfxException._message);
}
}
示例8: CreateBlankImage
void CreateBlankImage()
{
// this is the first time that we try to use the graphics driver,
// so it's the most likey place for a crash
try
{
Bitmap *blank = BitmapHelper::CreateBitmap(16, 16, final_col_dep);
blank = gfxDriver->ConvertBitmapToSupportedColourDepth(blank);
blank->Clear();
blankImage = gfxDriver->CreateDDBFromBitmap(blank, false, true);
blankSidebarImage = gfxDriver->CreateDDBFromBitmap(blank, false, true);
delete blank;
}
catch (Ali3DException gfxException)
{
quit((char*)gfxException._message);
}
}
示例9: update_walk_behind_images
void update_walk_behind_images()
{
int ee, rr;
int bpp = (thisroom.ebscene[play.bg_frame]->GetColorDepth() + 7) / 8;
Bitmap *wbbmp;
for (ee = 1; ee < MAX_OBJ; ee++)
{
update_polled_stuff_if_runtime();
if (walkBehindRight[ee] > 0)
{
wbbmp = BitmapHelper::CreateBitmap(
(walkBehindRight[ee] - walkBehindLeft[ee]) + 1,
(walkBehindBottom[ee] - walkBehindTop[ee]) + 1,
thisroom.ebscene[play.bg_frame]->GetColorDepth());
wbbmp->Clear(wbbmp->GetMaskColor());
int yy, startX = walkBehindLeft[ee], startY = walkBehindTop[ee];
for (rr = startX; rr <= walkBehindRight[ee]; rr++)
{
for (yy = startY; yy <= walkBehindBottom[ee]; yy++)
{
if (thisroom.object->GetScanLine(yy)[rr] == ee)
{
for (int ii = 0; ii < bpp; ii++)
wbbmp->GetScanLineForWriting(yy - startY)[(rr - startX) * bpp + ii] = thisroom.ebscene[play.bg_frame]->GetScanLine(yy)[rr * bpp + ii];
}
}
}
update_polled_stuff_if_runtime();
if (walkBehindBitmap[ee] != NULL)
{
gfxDriver->DestroyDDB(walkBehindBitmap[ee]);
}
walkBehindBitmap[ee] = gfxDriver->CreateDDBFromBitmap(wbbmp, false);
delete wbbmp;
}
}
walkBehindsCachedForBgNum = play.bg_frame;
}
示例10: DynamicSprite_Rotate
void DynamicSprite_Rotate(ScriptDynamicSprite *sds, int angle, int width, int height) {
if ((angle < 1) || (angle > 359))
quit("!DynamicSprite.Rotate: invalid angle (must be 1-359)");
if (sds->slot == 0)
quit("!DynamicSprite.Rotate: sprite has been deleted");
if ((width == SCR_NO_VALUE) || (height == SCR_NO_VALUE)) {
// calculate the new image size automatically
// 1 degree = 181 degrees in terms of x/y size, so % 180
int useAngle = angle % 180;
// and 0..90 is the same as 180..90
if (useAngle > 90)
useAngle = 180 - useAngle;
// useAngle is now between 0 and 90 (otherwise the sin/cos stuff doesn't work)
double angleInRadians = (double)useAngle * (M_PI / 180.0);
double sinVal = sin(angleInRadians);
double cosVal = cos(angleInRadians);
width = (cosVal * (double)spritewidth[sds->slot] + sinVal * (double)spriteheight[sds->slot]);
height = (sinVal * (double)spritewidth[sds->slot] + cosVal * (double)spriteheight[sds->slot]);
}
else {
multiply_up_coordinates(&width, &height);
}
// convert to allegro angle
angle = (angle * 256) / 360;
// resize the sprite to the requested size
Bitmap *newPic = BitmapHelper::CreateBitmap(width, height, spriteset[sds->slot]->GetColorDepth());
newPic->Clear(newPic->GetMaskColor());
// rotate the sprite about its centre
// (+ width%2 fixes one pixel offset problem)
newPic->RotateBlt(spriteset[sds->slot], width / 2 + width % 2, height / 2,
spritewidth[sds->slot] / 2, spriteheight[sds->slot] / 2, itofix(angle));
delete spriteset[sds->slot];
// replace the bitmap in the sprite set
add_dynamic_sprite(sds->slot, newPic, (game.spriteflags[sds->slot] & SPF_ALPHACHANNEL) != 0);
}
示例11: Render
void Rectangle::Render(Bitmap& bitmap)
{
if (IsVisible() && width_>0 && height_>0)
{
int x1=(int)(GetX()-GetOriginX());
int y1=(int)(GetY()-GetOriginY());
int x2=x1+(int)GetWidth()-1;
int y2=y1+(int)GetHeight()-1;
if (x1==0 && y1==0 && x2==bitmap.GetWidth()-1 && y2==bitmap.GetHeight()-1 && GetColor()==0 && GetAlpha()==255)
{
bitmap.Clear();
}
else
{
bitmap.Fill(x1,y1,x2,y2,GetColor(),GetAlpha());
}
}
}
示例12: DynamicSprite_ChangeCanvasSize
void DynamicSprite_ChangeCanvasSize(ScriptDynamicSprite *sds, int width, int height, int x, int y)
{
if (sds->slot == 0)
quit("!DynamicSprite.ChangeCanvasSize: sprite has been deleted");
if ((width < 1) || (height < 1))
quit("!DynamicSprite.ChangeCanvasSize: new size is too small");
multiply_up_coordinates(&x, &y);
multiply_up_coordinates(&width, &height);
Bitmap *newPic = BitmapHelper::CreateBitmap(width, height, spriteset[sds->slot]->GetColorDepth());
newPic->Clear(newPic->GetMaskColor());
// blit it into the enlarged image
newPic->Blit(spriteset[sds->slot], 0, 0, x, y, spritewidth[sds->slot], spriteheight[sds->slot]);
delete spriteset[sds->slot];
// replace the bitmap in the sprite set
add_dynamic_sprite(sds->slot, newPic, (game.spriteflags[sds->slot] & SPF_ALPHACHANNEL) != 0);
}
示例13: DynamicSprite_Create
ScriptDynamicSprite* DynamicSprite_Create(int width, int height, int alphaChannel)
{
multiply_up_coordinates(&width, &height);
int gotSlot = spriteset.findFreeSlot();
if (gotSlot <= 0)
return NULL;
Bitmap *newPic = BitmapHelper::CreateBitmap(width, height, final_col_dep);
if (newPic == NULL)
return NULL;
newPic->Clear(newPic->GetMaskColor());
if ((alphaChannel) && (final_col_dep < 32))
alphaChannel = false;
add_dynamic_sprite(gotSlot, gfxDriver->ConvertBitmapToSupportedColourDepth(newPic), alphaChannel != 0);
ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
GlobalReturnValue.SetDynamicObject(new_spr, new_spr);
return new_spr;
}
示例14: DynamicSprite_Flip
void DynamicSprite_Flip(ScriptDynamicSprite *sds, int direction) {
if ((direction < 1) || (direction > 3))
quit("!DynamicSprite.Flip: invalid direction");
if (sds->slot == 0)
quit("!DynamicSprite.Flip: sprite has been deleted");
// resize the sprite to the requested size
Bitmap *newPic = BitmapHelper::CreateBitmap(spritewidth[sds->slot], spriteheight[sds->slot], spriteset[sds->slot]->GetColorDepth());
newPic->Clear(newPic->GetMaskColor());
if (direction == 1)
newPic->FlipBlt(spriteset[sds->slot], 0, 0, Common::kBitmap_HFlip);
else if (direction == 2)
newPic->FlipBlt(spriteset[sds->slot], 0, 0, Common::kBitmap_VFlip);
else if (direction == 3)
newPic->FlipBlt(spriteset[sds->slot], 0, 0, Common::kBitmap_HVFlip);
delete spriteset[sds->slot];
// replace the bitmap in the sprite set
add_dynamic_sprite(sds->slot, newPic, (game.spriteflags[sds->slot] & SPF_ALPHACHANNEL) != 0);
}
示例15: switch
////////////////////////////////////////////////////////////////////////////////
// Draws a default skin bitmap
void MAS::Skin::GenerateDefaultBitmap(int i) {
Bitmap *bmp = bmpList[i];
static int w[] = { 64,64,18,26,72,18,18,11,15,15,15,15,36,64,18, 48,64,64,64,64,12,36,26,16,18,18,16,16,16,16,16,16,16,12, 2,18,64,88,88,30,30,30, 8, 8,12,30 };
static int h[] = { 64,64,72,52,72,80,88,88,56,56,56,56,96,64,24,112,64,64,64,64,36,12,52,64,64,64,64,64,64,64,64,48,64, 2,12,72,64,18,11, 8,30,36,72,72,17, 8 };
static int tw[] = { 60,58,14,13,68,18,14,11,15,15,15,15,32,60,18, 16,60,60,60,60, 8,14,13,16,14,14,12,16,16,16,12,12,12, 8, 2,14,60,18,22,-1,-1,-1,-1,-1,-1,-1 };
static int th[] = { 48,58,14,13,68,20,18,22,14,14,14,14, 8,60,12, 16,60,60,60,60,14, 8,13,16,12,12,12,16,16,16,12, 8,12, 2, 8,14,60,14,11,-1,-1,-1,-1,-1,-1,-1 };
bmp->Create(w[i], h[i], MAS::Settings::useVideoMemory ? Bitmap::VIDEO : Bitmap::MEMORY);
bmp->ThickX(tw[i]);
bmp->ThickY(th[i]);
bmp->Clear(c_face);
switch (i) {
case BOX:
bmp->Rectangle(1, 4, 63, 63, c_shad1);
bmp->Rectangle(0, 3, 62, 62, c_shad2);
break;
case BOX_SHADOW:
bmp->Draw3DFrame(0, 0, 62, 62, c_face, c_shad1, c_shad2);
bmp->Hline(1, 63, 63, Color::black);
bmp->Vline(63, 1, 63, Color::black);
break;
case BUTTON:
bmp->Draw3DFrame(0, 0, 17, 17, c_deselect, c_shad1, c_shad2);
bmp->Draw3DFrame(0, 18, 17, 35, c_select, c_shad2, c_shad1);
bmp->Draw3DFrame(0, 36, 17, 53, c_face, c_shad1, c_shad2);
bmp->Draw3DFrame(0, 54, 17, 71, c_focus, c_shad1, c_shad2);
break;
case CHECKBOX:
bmp->Draw3DFrame(0, 0, 12, 12, c_sunken, c_shad2, c_shad1);
bmp->Draw3DFrame(13, 0, 25, 12, c_sunken, c_shad2, c_shad1);
bmp->DrawXMark(19, 6, 6, c_font);
bmp->Draw3DFrame(0, 13, 12, 25, c_select, c_shad2, c_shad1);
bmp->Draw3DFrame(13, 13, 25, 25, c_select, c_shad2, c_shad1);
bmp->DrawXMark(19, 19, 6, c_font);
bmp->Draw3DFrame(0, 26, 12, 38, c_face, c_shad2, c_shad1);
bmp->Draw3DFrame(13, 26, 25, 38, c_face, c_shad2, c_shad1);
bmp->DrawXMark(19, 32, 6, c_disable);
bmp->Draw3DFrame(0, 39, 12, 51, c_focus, c_shad2, c_shad1);
bmp->Draw3DFrame(13,39, 25, 51, c_focus, c_shad2, c_shad1);
bmp->DrawXMark(19, 45, 6, c_font);
break;
case CLEAR_BACK:
bmp->Clear(c_back);
break;
case COMBO_BUTTON:
bmp->Clear(Color::transparent);
bmp->DrawArrow(4, 9, c_font, 3);
bmp->DrawArrow(4, 29, c_font, 3);
bmp->DrawArrow(4, 49, c_disable, 3);
bmp->DrawArrow(4, 69, c_font, 3);
break;
case HSLIDER_BACK:
bmp->Draw3DFrame(0, 9, 17, 12, Color::transparent, c_shad2, c_shad1);
bmp->Draw3DFrame(0, 31, 17, 34, Color::transparent, c_shad2, c_shad1);
bmp->Draw3DFrame(0, 53, 17, 56, Color::transparent, c_shad2, c_shad1);
bmp->Draw3DFrame(0, 75, 17, 78, Color::transparent, c_shad2, c_shad1);
break;
case HSLIDER_GRIP:
bmp->Draw3DFrame(0, 0, 10, 21, c_deselect, c_shad1, c_shad2);
bmp->Draw3DFrame(0, 22, 10, 43, c_select, c_shad2, c_shad1);
bmp->Draw3DFrame(0, 44, 10, 65, c_face, c_shad1, c_shad2);
bmp->Draw3DFrame(0, 66, 10, 87, c_focus, c_shad1, c_shad2);
break;
case ICONEXIT:
bmp->Draw3DFrame(0, 0, 14, 13, c_face, c_shad1, c_shad2);
bmp->Draw3DFrame(0, 14, 14, 27, c_face, c_shad2, c_shad1);
bmp->Draw3DFrame(0, 28, 14, 41, c_face, c_shad1, c_shad2);
bmp->Draw3DFrame(0, 42, 14, 55, c_face, c_shad1, c_shad2);
bmp->DrawXMark(7, 7, 6, c_font);
bmp->DrawXMark(7, 21, 6, c_font);
bmp->DrawXMark(7, 35, 6, c_disable);
bmp->DrawXMark(7, 49, 6, c_font);
break;
case ICONMAX:
bmp->Draw3DFrame(0, 0, 14, 13, c_face, c_shad1, c_shad2);
bmp->Draw3DFrame(0, 14, 14, 27, c_face, c_shad2, c_shad1);
bmp->Draw3DFrame(0, 28, 14, 41, c_face, c_shad1, c_shad2);
bmp->Draw3DFrame(0, 42, 14, 55, c_face, c_shad1, c_shad2);
bmp->Rectangle(3, 3, 10, 10, c_font);
bmp->Rectangle(3, 17, 10, 24, c_font);
bmp->Rectangle(3, 31, 10, 38, c_disable);
bmp->Rectangle(3, 45, 10, 52, c_font);
bmp->Hline(3, 4, 10, c_font);
bmp->Hline(3, 18, 10, c_font);
bmp->Hline(3, 32, 10, c_disable);
bmp->Hline(3, 46, 10, c_font);
break;
//.........这里部分代码省略.........