本文整理汇总了C++中BitmapRef::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapRef::GetWidth方法的具体用法?C++ BitmapRef::GetWidth怎么用?C++ BitmapRef::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitmapRef
的用法示例。
在下文中一共展示了BitmapRef::GetWidth方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: src
Window_ShopParty::Window_ShopParty(int ix, int iy, int iwidth, int iheight) :
Window_Base(ix, iy, iwidth, iheight) {
SetContents(Bitmap::Create(width - 16, height - 16));
contents->SetTransparentColor(windowskin->GetTransparentColor());
cycle = 0;
item_id = 0;
const std::vector<Game_Actor*>& actors = Game_Party::GetActors();
for (size_t i = 0; i < actors.size() && i < 4; i++) {
Game_Actor *actor = actors[i];
const std::string& sprite_name = actor->GetCharacterName();
int sprite_id = actor->GetCharacterIndex();
BitmapRef bm = Cache::Charset(sprite_name);
int width = bm->GetWidth() / 4 / 3;
int height = bm->GetHeight() / 2 / 4;
for (int j = 0; j < 3; j++) {
int sx = ((sprite_id % 4) * 3 + j) * width;
int sy = ((sprite_id / 4) * 4 + 2) * height;
Rect src(sx, sy, width, height);
for (int k = 0; k < 2; k++) {
BitmapRef bm2 = Bitmap::Create(width, height, true);
bm2->SetTransparentColor(bm->GetTransparentColor());
bm2->Clear();
bm2->Blit(0, 0, *bm, src, 255);
if (k == 0)
bm2->ToneBlit(0, 0, *bm2, bm2->GetRect(), Tone(0, 0, 0, 255));
bitmaps[i][j][k] = bm2;
}
}
}
Refresh();
}
示例2: Sprite
void Battle::Enemy::CreateSprite() {
BitmapRef graphic = Cache::Monster(rpg_enemy->battler_name);
bool hue_change = rpg_enemy->battler_hue != 0;
if (hue_change) {
BitmapRef new_graphic = Bitmap::Create(graphic->GetWidth(), graphic->GetHeight());
new_graphic->HueChangeBlit(0, 0, *graphic, graphic->GetRect(), rpg_enemy->battler_hue);
graphic = new_graphic;
}
sprite.reset(new Sprite());
sprite->SetBitmap(graphic);
sprite->SetOx(graphic->GetWidth() / 2);
sprite->SetOy(graphic->GetHeight() / 2);
sprite->SetX(member->x);
sprite->SetY(member->y);
sprite->SetZ(member->y);
sprite->SetVisible(!game_enemy->IsHidden());
}
示例3:
void BattleAnimation::OnBattle2SpriteReady(FileRequestResult* result) {
if (result->success) {
BitmapRef bitmap = Cache::Battle2(result->file);
if (bitmap->GetWidth() == 640) {
large = true;
}
SetBitmap(bitmap);
SetSrcRect(Rect(0, 0, 0, 0));
}
else {
Output::Warning("Couldn't find animation: %s", result->file.c_str());
}
}
示例4: OnBattleSpriteReady
void BattleAnimation::OnBattleSpriteReady(FileRequestResult* result) {
if (result->success) {
//Normally only battle2 sprites are "large" sprites - but the check doesn't hurt.
BitmapRef bitmap = Cache::Battle(result->file);
if (bitmap->GetWidth() == 640) {
large = true;
}
SetBitmap(bitmap);
SetSrcRect(Rect(0, 0, 0, 0));
}
else {
// Try battle2
FileRequestAsync* request = AsyncHandler::RequestFile("Battle2", result->file);
request_id = request->Bind(&BattleAnimation::OnBattle2SpriteReady, this);
request->Start();
}
}
示例5: OnCharsetSpriteReady
void Window_ShopParty::OnCharsetSpriteReady(FileRequestResult* /* result */, int party_index) {
Game_Actor *actor = Main_Data::game_party->GetActors()[party_index];
const std::string& sprite_name = actor->GetSpriteName();
int sprite_id = actor->GetSpriteIndex();
BitmapRef bm = Cache::Charset(sprite_name);
int width = bm->GetWidth() / 4 / 3;
int height = bm->GetHeight() / 2 / 4;
for (int j = 0; j < 3; j++) {
int sx = ((sprite_id % 4) * 3 + j) * width;
int sy = ((sprite_id / 4) * 4 + 2) * height;
Rect src(sx, sy, width, height);
for (int k = 0; k < 2; k++) {
BitmapRef bm2 = Bitmap::Create(width, height, true);
bm2->Clear();
bm2->Blit(0, 0, *bm, src, 255);
if (k == 0)
bm2->ToneBlit(0, 0, *bm2, bm2->GetRect(), Tone(128, 128, 128, 0), Opacity::opaque);
bitmaps[party_index][j][k] = bm2;
}
}
}
示例6: Draw
void Text::Draw(Bitmap& dest, int x, int y, int color, std::string const& text, Text::Alignment align) {
if (text.length() == 0) return;
FontRef font = dest.GetFont();
Rect dst_rect = Font::Default()->GetSize(text);
switch (align) {
case Text::AlignCenter:
dst_rect.x = x - dst_rect.width / 2;
break;
case Text::AlignRight:
dst_rect.x = x - dst_rect.width;
break;
case Text::AlignLeft:
dst_rect.x = x;
break;
default:
assert(false);
}
dst_rect.y = y;
dst_rect.width += 1;
dst_rect.height += 1; // Need place for shadow
if (dst_rect.IsOutOfBounds(dest.GetWidth(), dest.GetHeight())) return;
BitmapRef text_surface; // Complete text will be on this surface
text_surface = Bitmap::Create(dst_rect.width, dst_rect.height, true);
text_surface->SetTransparentColor(dest.GetTransparentColor());
text_surface->Clear();
// Load the system file for the shadow and text color
BitmapRef system = Cache::System(Data::system.system_name);
// Load the exfont-file
BitmapRef exfont = Cache::Exfont();
// Get the Shadow color
Color shadow_color(Cache::system_info.sh_color);
// If shadow is pure black, increase blue channel
// so it doesn't become transparent
if ((shadow_color.red == 0) &&
(shadow_color.green == 0) &&
(shadow_color.blue == 0) ) {
if (text_surface->bytes() >= 3) {
shadow_color.blue++;
} else {
shadow_color.blue += 8;
}
}
// Where to draw the next glyph (x pos)
int next_glyph_pos = 0;
// The current char is an exfont
bool is_exfont = false;
// This loops always renders a single char, color blends it and then puts
// it onto the text_surface (including the drop shadow)
for (boost::u8_to_u32_iterator<std::string::const_iterator>
c(text.begin(), text.begin(), text.end()),
end(text.end(), text.begin(), text.end()); c != end; ++c) {
Rect next_glyph_rect(next_glyph_pos, 0, 0, 0);
boost::u8_to_u32_iterator<std::string::const_iterator> next_c_it = boost::next(c);
uint32_t const next_c = std::distance(c, end) > 1? *next_c_it : 0;
// ExFont-Detection: Check for A-Z or a-z behind the $
if (*c == '$' && std::isalpha(next_c)) {
int exfont_value = -1;
// Calculate which exfont shall be rendered
if (islower(next_c)) {
exfont_value = 26 + next_c - 'a';
} else if (isupper(next_c)) {
exfont_value = next_c - 'A';
} else {
assert(false);
}
is_exfont = true;
BitmapRef mask = Bitmap::Create(12, 12, true);
// Get exfont from graphic
Rect const rect_exfont((exfont_value % 13) * 12, (exfont_value / 13) * 12, 12, 12);
// Create a mask
mask->Clear();
mask->Blit(0, 0, *exfont, rect_exfont, 255);
// Get color region from system graphic
Rect clip_system(8+16*(color%10), 4+48+16*(color/10), 6, 12);
BitmapRef char_surface = Bitmap::Create(mask->GetWidth(), mask->GetHeight(), true);
char_surface->SetTransparentColor(dest.GetTransparentColor());
char_surface->Clear();
// Blit gradient color background (twice because of full glyph)
char_surface->Blit(0, 0, *system, clip_system, 255);
char_surface->Blit(6, 0, *system, clip_system, 255);
// Blit mask onto background
//.........这里部分代码省略.........