当前位置: 首页>>代码示例>>C++>>正文


C++ BitmapRef类代码示例

本文整理汇总了C++中BitmapRef的典型用法代码示例。如果您正苦于以下问题:C++ BitmapRef类的具体用法?C++ BitmapRef怎么用?C++ BitmapRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BitmapRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

BitmapRef FTFont::Glyph(char32_t glyph) {
	if(!check_face()) {
		return Font::Default()->Glyph(glyph);
	}

	if (FT_Load_Char(face_.get(), glyph, FT_LOAD_NO_BITMAP) != FT_Err_Ok) {
		Output::Error("Couldn't load FreeType character %d", glyph);
	}

    if (FT_Render_Glyph(face_->glyph, FT_RENDER_MODE_MONO) != FT_Err_Ok) {
		Output::Error("Couldn't render FreeType character %d", glyph);
	}

	FT_Bitmap const& ft_bitmap = face_->glyph->bitmap;
	assert(face_->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO);

	size_t const pitch = std::abs(ft_bitmap.pitch);
	int const width = ft_bitmap.width;
	int const height = ft_bitmap.rows;

	BitmapRef bm = Bitmap::Create(nullptr, width, height, 0, DynamicFormat(8,8,0,8,0,8,0,8,0,PF::Alpha));
	uint8_t* data = reinterpret_cast<uint8_t*>(bm->pixels());
	int dst_pitch = bm->pitch();

	for(int row = 0; row < height; ++row) {
		for(int col = 0; col < width; ++col) {
			unsigned c = ft_bitmap.buffer[pitch * row + (col/8)];
			unsigned bit = 7 - (col%8);
			data[row * dst_pitch + col] = (c & (0x01 << bit)) ? 255 : 0;
		}
	}

	return bm;
}
开发者ID:ChristianBreitwieser,项目名称:easyrpg-libretro,代码行数:34,代码来源:font.cpp

示例2: HandleErrorOutput

static void HandleErrorOutput(const std::string& err) {
	// Drawing directly on the screen because message_overlay is not visible
	// when faded out
	BitmapRef surface = DisplayUi->GetDisplaySurface();
	surface->FillRect(surface->GetRect(), Color(255, 0, 0, 128));

	std::string error = "Error:\n";
	error += err;
	error += "\n\nEasyRPG Player will close now. Press any key...";

	Text::Draw(*surface, 11, 11, Color(0, 0, 0, 255), error);
	Text::Draw(*surface, 10, 10, Color(255, 255, 255, 255), error);
	DisplayUi->UpdateDisplay();

	if (ignore_pause) { return; }

	Input::ResetKeys();
	while (!Input::IsAnyPressed()) {
		DisplayUi->Sleep(1);
		DisplayUi->ProcessEvents();

		if (Player::exit_flag) break;

		Input::Update();
	}
	Input::ResetKeys();
	Graphics::FrameReset();
	DisplayUi->UpdateDisplay();
}
开发者ID:joewagenbrenner,项目名称:Player,代码行数:29,代码来源:output.cpp

示例3: HandleErrorOutput

static void HandleErrorOutput(const std::string& err) {
#ifdef EMSCRIPTEN
	// Do not execute any game logic after an error happened
	emscripten_cancel_main_loop();
#endif

	// Drawing directly on the screen because message_overlay is not visible
	// when faded out
	BitmapRef surface = DisplayUi->GetDisplaySurface();
	surface->FillRect(surface->GetRect(), Color(255, 0, 0, 128));

	std::string error = "Error:\n";
	error += err;

	error += "\n\nEasyRPG Player will close now.\nPress [ENTER] key to exit...";

	Text::Draw(*surface, 11, 11, Color(0, 0, 0, 255), error);
	Text::Draw(*surface, 10, 10, Color(255, 255, 255, 255), error);
	DisplayUi->UpdateDisplay();

	if (ignore_pause) { return; }

	Input::ResetKeys();
	while (!Input::IsAnyPressed()) {
		DisplayUi->Sleep(1);
		DisplayUi->ProcessEvents();

		if (Player::exit_flag) break;

		Input::Update();
	}
}
开发者ID:melissabouchafaa,项目名称:Player,代码行数:32,代码来源:output.cpp

示例4: GenerateAutotiles

BitmapScreenRef TilemapLayer::GenerateAutotiles(int count, const std::map<uint32_t, TileXY>& map) {
	int rows = (count + TILES_PER_ROW - 1) / TILES_PER_ROW;
	BitmapRef tiles = Bitmap::Create(TILES_PER_ROW * TILE_SIZE, rows * TILE_SIZE);
	tiles->Clear();
	Rect rect(0, 0, TILE_SIZE/2, TILE_SIZE/2);

	std::map<uint32_t, TileXY>::const_iterator it;
	for (it = map.begin(); it != map.end(); ++it) {
		uint32_t quarters_hash = it->first;
		TileXY dst = it->second;

		// unpack the quarters data
		for (int j = 0; j < 2; j++) {
			for (int i = 0; i < 2; i++) {
				int x = quarters_hash >> 28;
				quarters_hash <<= 4;
				
				int y = quarters_hash >> 28;
				quarters_hash <<= 4;
				
				rect.x = (x * 2 + i) * (TILE_SIZE/2);
				rect.y = (y * 2 + j) * (TILE_SIZE/2);
				tiles->Blit((dst.x * 2 + i) * (TILE_SIZE/2), (dst.y * 2 + j) * (TILE_SIZE/2), *chipset, rect, 255);
			}
		}
	}

	return BitmapScreen::Create(tiles);
}
开发者ID:Shin-NiL,项目名称:Player,代码行数:29,代码来源:tilemap_layer.cpp

示例5: Window_Base

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();
}
开发者ID:Bonstra,项目名称:EasyRPG-Player,代码行数:35,代码来源:window_shopparty.cpp

示例6: rect

void TilemapLayer::DrawTile(Bitmap& screen, int x, int y, int row, int col, bool autotile) {
	if (!autotile && screen.GetTileOpacity(row, col) == Bitmap::Transparent)
		return;
	Rect rect(col * TILE_SIZE, row * TILE_SIZE, TILE_SIZE, TILE_SIZE);

	BitmapRef dst = DisplayUi->GetDisplaySurface();
	dst->Blit(x, y, screen, rect, 255);
}
开发者ID:t3573393,项目名称:Player,代码行数:8,代码来源:tilemap_layer.cpp

示例7: EffectsBlit

// Waver, Zoom, Split Opacity
void Bitmap::EffectsBlit(int x, int y, Bitmap const& src, Rect const& src_rect,
						   int top_opacity, int bottom_opacity, int opacity_split,
						   double zoom_x, double zoom_y,
						   int waver_depth, double waver_phase) {
	int zoomed_width  = (int)(src_rect.width  * zoom_x);
	int zoomed_height = (int)(src_rect.height * zoom_y);
	BitmapRef draw = src.Resample(zoomed_width, zoomed_height, src_rect);
	EffectsBlit(x, y, *draw, draw->GetRect(),
				top_opacity, bottom_opacity, (int) (opacity_split * zoom_y),
				waver_depth, waver_phase);
}
开发者ID:Bonstra,项目名称:EasyRPG-Player,代码行数:12,代码来源:effects.cpp

示例8: Refresh

void Window_ShopParty::Refresh() {
	contents->Clear();

	BitmapRef system = Cache::System();

	if (item_id <= 0 || item_id > static_cast<int>(Data::items.size()))
		return;

	const std::vector<Game_Actor*>& actors = Main_Data::game_party->GetActors();
	for (size_t i = 0; i < actors.size() && i < 4; i++) {
		Game_Actor *actor = actors[i];
		int phase = (cycle / anim_rate) % 4;
		if (phase == 3) {
			phase = 1;
		}
		bool usable = actor->IsEquippable(item_id);
		BitmapRef bm = bitmaps[i][usable ? phase : 1][usable ? 1 : 0];

		if (bm) {
			contents->Blit(i * 32, 0, *bm, bm->GetRect(), 255);
		}

		// (Shop) items are guaranteed to be valid
		const auto* new_item = ReaderUtil::GetElement(Data::items, item_id);

		bool equippable = usable && IsEquipment(new_item);

		if (equippable) {
			// check if item is equipped by each member
			bool is_equipped = false;
			for (int j = 1; j <= 5; ++j) {
				const RPG::Item* item = actor->GetEquipment(j);
				if (item) {
					is_equipped |= (item->ID == item_id);
				}
			}
			if (is_equipped)
				contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 24, 8, 8), 255);
			else {
				int cmp = CmpEquip(actor, new_item);
				if (cmp > 0) {
					contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 0, 8, 8), 255);
				}
				else if (cmp < 0) {
					contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 16, 8, 8), 255);
				}
				else {
					contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 8, 8, 8), 255);
				}
			}
		}
	}
}
开发者ID:EasyRPG,项目名称:Player,代码行数:53,代码来源:window_shopparty.cpp

示例9: BlitScreenIntern

void Sprite::BlitScreenIntern(Bitmap const& draw_bitmap,
								Rect const& src_rect, int opacity_split) const {
	BitmapRef dst = DisplayUi->GetDisplaySurface();

	double zoom_x = zoom_x_effect;
	double zoom_y = zoom_y_effect;

	dst->EffectsBlit(x, y, ox, oy, draw_bitmap, src_rect,
					 Opacity(opacity_top_effect, opacity_bottom_effect, opacity_split),
					 zoom_x, zoom_y, angle_effect != 0.0 ? angle_effect * 3.14159 / 180 : 0.0,
					 waver_effect_depth, waver_effect_phase);
}
开发者ID:EasyRPG,项目名称:Player,代码行数:12,代码来源:sprite.cpp

示例10:

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());
	}
}
开发者ID:ChristianBreitwieser,项目名称:easyrpg-libretro,代码行数:13,代码来源:battle_animation.cpp

示例11: RefreshBackground

void Window::RefreshBackground() {
	background_needs_refresh = false;

	BitmapRef bitmap = Bitmap::Create(width, height, false);

	if (stretch) {
		bitmap->StretchBlit(*windowskin, Rect(0, 0, 32, 32), 255);
	} else {
		bitmap->TiledBlit(Rect(0, 0, 16, 16), *windowskin, bitmap->GetRect(), 255);
	}

	background->SetBitmap(bitmap);
}
开发者ID:cheerjo,项目名称:Player,代码行数:13,代码来源:window.cpp

示例12: func_

BitmapRef ShinonomeFont::Glyph(char32_t code) {
	ShinonomeGlyph const* const glyph = func_(code);
	assert(glyph);
	size_t const width = glyph->is_full? FULL_WIDTH : HALF_WIDTH;

	BitmapRef bm = Bitmap::Create(nullptr, width, HEIGHT, 0, DynamicFormat(8,8,0,8,0,8,0,8,0,PF::Alpha));
	uint8_t* data = reinterpret_cast<uint8_t*>(bm->pixels());
	int pitch = bm->pitch();
	for(size_t y_ = 0; y_ < HEIGHT; ++y_)
		for(size_t x_ = 0; x_ < width; ++x_)
			data[y_*pitch+x_] = (glyph->data[y_] & (0x1 << x_)) ? 255 : 0;

	return bm;
}
开发者ID:ChristianBreitwieser,项目名称:easyrpg-libretro,代码行数:14,代码来源:font.cpp

示例13: rect

void TilemapLayer::DrawTile(Bitmap& screen, int x, int y, int row, int col, bool autotile) {
	Bitmap::TileOpacity op = screen.GetTileOpacity(row, col);

	if (!fast_blit && op == Bitmap::Transparent)
		return;
	Rect rect(col * TILE_SIZE, row * TILE_SIZE, TILE_SIZE, TILE_SIZE);

	BitmapRef dst = DisplayUi->GetDisplaySurface();

	if (fast_blit || op == Bitmap::Opaque) {
		dst->BlitFast(x, y, screen, rect, 255);
	} else {
		dst->Blit(x, y, screen, rect, 255);
	}
}
开发者ID:FaithFeather,项目名称:Player,代码行数:15,代码来源:tilemap_layer.cpp

示例14: BlitScreenIntern

void BitmapScreen::BlitScreenIntern(Bitmap const& draw_bitmap, int x, int y,
									Rect const& src_rect, bool need_scale, int bush_y) {
	if (! &draw_bitmap)
		return;

	BitmapRef dst = DisplayUi->GetDisplaySurface();

	int opacity_split = bush_y;

	double zoom_x = need_scale ? zoom_x_effect : 1.0;
	double zoom_y = need_scale ? zoom_y_effect : 1.0;

	dst->EffectsBlit(x, y, draw_bitmap, src_rect,
					 opacity_top_effect, opacity_bottom_effect, opacity_split,
					 Tone(), zoom_x, zoom_y, angle_effect * 3.14159 / 180,
					 waver_effect_depth, waver_effect_phase);
}
开发者ID:ChrisOelmueller,项目名称:Player,代码行数:17,代码来源:bitmap_screen.cpp

示例15: 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();
	}
}
开发者ID:ChristianBreitwieser,项目名称:easyrpg-libretro,代码行数:18,代码来源:battle_animation.cpp


注:本文中的BitmapRef类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。