mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:27:35 +00:00
Start working on a simple Launcher app.
Let GButton have an optional icon (GraphicsBitmap) that gets rendered in the middle of the button if present. Also add GraphicsBitmap::load_from_file() which allows mmap'ed RGBA32 files. I wrote a little program to take "raw" files from GIMP and swizzle them into the correct byte order.
This commit is contained in:
parent
71b9ec1ae0
commit
887b4a7a1a
29 changed files with 293 additions and 11 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue