image::paste throws exception if graphics or image is empty

This commit is contained in:
Jinhao
2015-07-13 00:23:54 +08:00
parent 17556cae99
commit 1eb76307e4
15 changed files with 59 additions and 642 deletions

View File

@@ -100,8 +100,8 @@ namespace detail
void blend(drawable_type dw, const rectangle& area, pixel_color_t color, double fade_rate)
{
if(fade_rate <= 0) return;
if(fade_rate > 1) fade_rate = 1;
if (fade_rate <= 0) return;
if (fade_rate > 1) fade_rate = 1;
rectangle r;
if (false == ::nana::overlap(rectangle{ drawable_size(dw) }, area, r))
@@ -114,11 +114,11 @@ namespace detail
double lrate = 1 - fade_rate;
pixel_buffer pixbuf(dw, r.y, r.height);
for(std::size_t row = 0; row < r.height; ++row)
for (std::size_t row = 0; row < r.height; ++row)
{
auto i = pixbuf.raw_ptr(row) + r.x;
const auto end = i + r.width;
for(; i < end; ++i)
for (; i < end; ++i)
{
unsigned px_r = ((static_cast<unsigned>((i->value & 0xFF0000) * lrate) + red) & 0xFF0000);
unsigned px_g = ((static_cast<unsigned>((i->value & 0xFF00) * lrate) + green) & 0xFF00);
@@ -126,7 +126,7 @@ namespace detail
i->value = (px_r | px_g | px_b);
}
}
pixbuf.paste(nana::rectangle(r.x, 0, r.width, r.height), dw, r.x, r.y);
pixbuf.paste(nana::rectangle(r.x, 0, r.width, r.height), dw, point{r.x, r.y});
}
nana::size raw_text_extent_size(drawable_type dw, const nana::char_t* text, std::size_t len)