summaryrefslogtreecommitdiff
path: root/SharedGraphics/Painter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SharedGraphics/Painter.cpp')
-rw-r--r--SharedGraphics/Painter.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/SharedGraphics/Painter.cpp b/SharedGraphics/Painter.cpp
index 486352a958..8f7ead9c21 100644
--- a/SharedGraphics/Painter.cpp
+++ b/SharedGraphics/Painter.cpp
@@ -368,6 +368,7 @@ void Painter::draw_focus_rect(const Rect& rect)
void Painter::blit(const Point& position, const GraphicsBitmap& source, const Rect& src_rect)
{
Rect dst_rect(position, src_rect.size());
+ dst_rect.move_by(m_translation);
dst_rect.intersect(m_clip_rect);
RGBA32* dst = m_target->scanline(dst_rect.y()) + dst_rect.x();
@@ -383,6 +384,33 @@ void Painter::blit(const Point& position, const GraphicsBitmap& source, const Re
}
}
+void Painter::blit_with_alpha(const Point& position, const GraphicsBitmap& source, const Rect& src_rect)
+{
+ Rect dst_rect(position, src_rect.size());
+ dst_rect.move_by(m_translation);
+ dst_rect.intersect(m_clip_rect);
+
+ RGBA32* dst = m_target->scanline(dst_rect.y()) + dst_rect.x();
+ const RGBA32* src = source.scanline(src_rect.top()) + src_rect.left();
+
+ const unsigned dst_skip = m_target->width();
+ const unsigned src_skip = source.width();
+
+ for (int i = dst_rect.height() - 1; i >= 0; --i) {
+ for (int x = 0; x < dst_rect.width(); ++x) {
+ byte alpha = Color(src[x]).alpha();
+ if (alpha == 0xff)
+ dst[x] = src[x];
+ else if (!alpha)
+ continue;
+ else
+ dst[x] = Color(dst[x]).blend(src[x]).value();
+ }
+ dst += dst_skip;
+ src += src_skip;
+ }
+}
+
void Painter::set_clip_rect(const Rect& rect)
{
m_clip_rect = Rect::intersection(rect, m_target->rect());