本文整理汇总了C++中Rect::IsOutOfBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::IsOutOfBounds方法的具体用法?C++ Rect::IsOutOfBounds怎么用?C++ Rect::IsOutOfBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect::IsOutOfBounds方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Copy
///////////////////////////////////////////////////////////
/// Copy
///////////////////////////////////////////////////////////
void Bitmap::Copy(int x, int y, Bitmap* src_bitmap, Rect src_rect) {
if (src_bitmap->GetWidth() == 0 || src_bitmap->GetHeight() == 0 || width == 0 || height == 0) return;
if (x >= width || y >= height) return;
if (x < 0) {
src_rect.x -= x;
x = 0;
}
if (y < 0) {
src_rect.y -= y;
y = 0;
}
src_rect.Adjust(src_bitmap->GetWidth(), src_bitmap->GetHeight());
if (src_rect.IsOutOfBounds(src_bitmap->GetWidth(), src_bitmap->GetHeight())) return;
int src_width = src_rect.width;
int src_height = src_rect.height;
if (x + src_width > width) src_width = width - x;
if (y + src_height > height) src_height = height - y;
if (src_width <= 0 || src_height <= 0) return;
int src_pitch = src_width * 4;
int src_row = src_bitmap->GetWidth();
const Uint32* src_pixels = ((Uint32*)(&src_bitmap->pixels[0])) + src_rect.x + src_rect.y * src_bitmap->GetWidth();
Uint32* dst_pixels = ((Uint32*)(&pixels[0])) + x + y * width;
for (int i = 0; i < src_height; ++i) {
memcpy(dst_pixels, src_pixels, src_pitch);
src_pixels += src_row;
dst_pixels += width;
}
Changed();
}
示例2: HSLChange
void Bitmap::HSLChange(double h, double s, double l, Rect rect) {
rect.Adjust(GetWidth(), GetHeight());
if (rect.IsOutOfBounds(GetWidth(), GetHeight())) return;
for (int i = rect.y; i < rect.y + rect.height; i++) {
for (int j = rect.x; j < rect.x + rect.width; j++) {
Color color = Color::NewUint32(pixels[(i * width) + j]);
pixels[(i * width) + j] = RGBAdjustHSL(color, h, s, l).GetUint32();
}
}
Changed();
}
示例3: FillRect
///////////////////////////////////////////////////////////
/// Fill rect
///////////////////////////////////////////////////////////
void Bitmap::FillRect(Rect rect, Color color) {
rect.Adjust(GetWidth(), GetHeight());
if (rect.IsOutOfBounds(GetWidth(), GetHeight())) return;
long dst = rect.x + rect.y * width;
Uint32 col = color.GetUint32();
for (int i = 0; i < rect.height; i++) {
fill_n(pixels.begin() + dst, rect.width, col);
dst += width;
}
Changed();
}
示例4: StretchBlit
///////////////////////////////////////////////////////////
/// Stretch blit
///////////////////////////////////////////////////////////
void Bitmap::StretchBlit(Rect dst_rect, Bitmap* src_bitmap, Rect src_rect, int opacity) {
if (src_rect.width == dst_rect.width && src_rect.height == dst_rect.height) {
Blit(dst_rect.x, dst_rect.y, src_bitmap, src_rect, opacity);
} else {
src_rect.Adjust(src_bitmap->GetWidth(), src_bitmap->GetHeight());
if (src_rect.IsOutOfBounds(src_bitmap->GetWidth(), src_bitmap->GetHeight())) return;
Bitmap* resampled = src_bitmap->Resample(dst_rect.width, dst_rect.height, src_rect);
Rect rect(0, 0, dst_rect.width, dst_rect.height);
Blit(dst_rect.x, dst_rect.y, resampled, rect, opacity);
delete resampled;
}
Changed();
}
示例5: Blit
///////////////////////////////////////////////////////////
/// Blit
///////////////////////////////////////////////////////////
void Bitmap::Blit(int x, int y, Bitmap* src_bitmap, Rect src_rect, int opacity) {
if (src_bitmap->GetWidth() == 0 || src_bitmap->GetHeight() == 0 || width == 0 || height == 0) return;
if (x >= width || y >= height) return;
if (x < 0) {
src_rect.x -= x;
x = 0;
}
if (y < 0) {
src_rect.y -= y;
y = 0;
}
src_rect.Adjust(src_bitmap->GetWidth(), src_bitmap->GetHeight());
if (src_rect.IsOutOfBounds(src_bitmap->GetWidth(), src_bitmap->GetHeight())) return;
int src_width = src_rect.width;
int src_height = src_rect.height;
if (x + src_width > width) src_width = width - x;
if (y + src_height > height) src_height = height - y;
if (src_width <= 0 || src_height <= 0) return;
int src_row = src_bitmap->GetWidth() * 4;
int dst_row = width * 4;
const Uint8* src_pixels = ((Uint8*)(&src_bitmap->pixels[0])) + (src_rect.x + src_rect.y * src_bitmap->GetWidth()) * 4;
Uint8* dst_pixels = ((Uint8*)(&pixels[0])) + (x + y * width) * 4;
if (opacity > 255) opacity = 255;
if (opacity > 0) {
for (int i = 0; i < src_height; ++i) {
for (int j = 0; j < src_width; ++j) {
const Uint8* src = src_pixels + j * 4;
Uint8* dst = dst_pixels + j * 4;
Uint8 srca = (Uint8)(src[3] * opacity / 255);
dst[0] = (dst[0] * (255 - srca) + src[0] * srca) / 255;
dst[1] = (dst[1] * (255 - srca) + src[1] * srca) / 255;
dst[2] = (dst[2] * (255 - srca) + src[2] * srca) / 255;
dst[3] = dst[3] * (255 - srca) / 255 + srca;
}
src_pixels += src_row;
dst_pixels += dst_row;
}
}
Changed();
}
示例6: TextDraw
///////////////////////////////////////////////////////////
/// Draw text
///////////////////////////////////////////////////////////
void Bitmap::TextDraw(Rect rect, std::string text, int align) {
if (text.length() == 0) return;
if (rect.IsOutOfBounds(GetWidth(), GetHeight())) return;
VALUE font_id = rb_iv_get(id, "@font");
VALUE name_id = rb_iv_get(font_id, "@name");
Color color = Color(rb_iv_get(font_id, "@color"));
int size = NUM2INT(rb_iv_get(font_id, "@size"));
bool bold = NUM2BOOL(rb_iv_get(font_id, "@bold"));
bool italic = NUM2BOOL(rb_iv_get(font_id, "@italic"));
Bitmap* text_bmp = Text::Draw(text, StringValuePtr(name_id), color, size, bold, italic, false);
if (text_bmp->GetWidth() > rect.width) {
int stretch = (int)(text_bmp->GetWidth() * 0.4);
if (rect.width > stretch) stretch = rect.width;
Rect resample_rect(0, 0, text_bmp->GetWidth(), text_bmp->GetHeight());
Bitmap* resampled = text_bmp->Resample(stretch, text_bmp->GetHeight(), resample_rect);
delete text_bmp;
text_bmp = resampled;
}
Rect src_rect(0, 0, rect.width, rect.height);
int y = rect.y;
if (rect.height > text_bmp->GetHeight()) y += ((rect.height - text_bmp->GetHeight()) / 2);
int x = rect.x;
if (rect.width > text_bmp->GetWidth()) {
if (align == 1) {
x += (rect.width - text_bmp->GetWidth()) / 2;
} else if (align == 2) {
x += rect.width - text_bmp->GetWidth();
}
}
Blit(x, y, text_bmp, src_rect, (int)color.alpha);
delete text_bmp;
Changed();
}
示例7: Refresh
BitmapRef BitmapScreen::Refresh(Rect& rect, bool& need_scale, int& bush_y) {
need_scale = false;
rect.Adjust(bitmap->GetWidth(), bitmap->GetHeight());
if (rect.IsOutOfBounds(bitmap->GetWidth(), bitmap->GetHeight()))
return BitmapRef();
bool no_tone = tone_effect == Tone();
bool no_flash = flash_effect.alpha == 0;
bool no_flip = !flipx_effect && !flipy_effect;
bool no_effects = no_tone && no_flash && no_flip;
bool no_zoom = zoom_x_effect == 1.0 && zoom_y_effect == 1.0;
bool effects_changed = tone_effect != current_tone ||
flash_effect != current_flash ||
flipx_effect != current_flip_x ||
flipy_effect != current_flip_y;
bool effects_rect_changed = rect != bitmap_effects_src_rect;
if (effects_changed || effects_rect_changed || bitmap_changed) {
bitmap_effects_valid = false;
bitmap_scale_valid = false;
}
if (no_effects && no_zoom)
return bitmap;
if (bitmap_effects != NULL && bitmap_effects_valid && no_zoom)
return bitmap_effects;
BitmapRef src_bitmap;
if (no_effects)
src_bitmap = bitmap;
else if (bitmap_effects_valid)
src_bitmap = bitmap_effects;
else {
current_tone = tone_effect;
current_flash = flash_effect;
current_flip_x = flipx_effect;
current_flip_y = flipy_effect;
if (bitmap_effects != NULL &&
bitmap_effects->GetWidth() < rect.x + rect.width &&
bitmap_effects->GetHeight() < rect.y + rect.height) {
bitmap_effects.reset();
}
if (!bitmap_effects)
bitmap_effects = Bitmap::Create(bitmap->GetWidth(), bitmap->GetHeight(), true);
bitmap_effects->Clear();
if (no_tone && no_flash)
bitmap_effects->FlipBlit(rect.x, rect.y, *bitmap, rect, flipx_effect, flipy_effect);
else if (no_flip && no_flash)
bitmap_effects->ToneBlit(rect.x, rect.y, *bitmap, rect, tone_effect);
else if (no_flip && no_tone)
bitmap_effects->BlendBlit(rect.x, rect.y, *bitmap, rect, flash_effect);
else if (no_flash) {
bitmap_effects->ToneBlit(rect.x, rect.y, *bitmap, rect, tone_effect);
bitmap_effects->Flip(rect, flipx_effect, flipy_effect);
}
else if (no_tone) {
bitmap_effects->BlendBlit(rect.x, rect.y, *bitmap, rect, flash_effect);
bitmap_effects->Flip(rect, flipx_effect, flipy_effect);
}
else if (no_flip) {
bitmap_effects->BlendBlit(rect.x, rect.y, *bitmap, rect, flash_effect);
bitmap_effects->ToneBlit(rect.x, rect.y, *bitmap_effects, rect, tone_effect);
}
else {
bitmap_effects->BlendBlit(rect.x, rect.y, *bitmap, rect, flash_effect);
bitmap_effects->ToneBlit(rect.x, rect.y, *bitmap_effects, rect, tone_effect);
bitmap_effects->Flip(rect, flipx_effect, flipy_effect);
}
bitmap_effects_src_rect = rect;
bitmap_effects_valid = true;
src_bitmap = bitmap_effects;
}
if (no_zoom || angle_effect != 0.0)
return src_bitmap;
int zoomed_width = (int)(rect.width * zoom_x_effect);
int zoomed_height = (int)(rect.height * zoom_y_effect);
if (zoomed_width > 640 || zoomed_height > 640) {
need_scale = true;
return src_bitmap;
}
bool zoom_changed =
zoom_x_effect != current_zoom_x ||
zoom_y_effect != current_zoom_y;
bool scale_rect_changed = rect != bitmap_scale_src_rect;
if (zoom_changed || scale_rect_changed)
//.........这里部分代码省略.........