Prevent image downscaling on every refresh (ModelBmp)
This commit is contained in:
committed by
Raphael Coeffic
parent
06335e596d
commit
a37d3900c5
@@ -33,6 +33,10 @@ class ModelBitmapWidget: public Widget
|
|||||||
|
|
||||||
void refresh(BitmapBuffer * dc) override
|
void refresh(BitmapBuffer * dc) override
|
||||||
{
|
{
|
||||||
|
if (buffer && ((buffer->width() != width()) || (buffer->height() != height()))) {
|
||||||
|
loadBitmap();
|
||||||
|
}
|
||||||
|
|
||||||
// big space to draw
|
// big space to draw
|
||||||
if (rect.h >= 96 && rect.w >= 120) {
|
if (rect.h >= 96 && rect.w >= 120) {
|
||||||
|
|
||||||
@@ -47,12 +51,12 @@ class ModelBitmapWidget: public Widget
|
|||||||
dc->drawSolidFilledRect(39, 27, rect.w - 48, 2, MAINVIEW_GRAPHICS_COLOR);
|
dc->drawSolidFilledRect(39, 27, rect.w - 48, 2, MAINVIEW_GRAPHICS_COLOR);
|
||||||
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
dc->drawScaledBitmap(buffer.get(), 0, 38, rect.w, rect.h - 38);
|
dc->drawBitmap(0, 38, buffer.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// smaller space to draw
|
// smaller space to draw
|
||||||
else if (buffer) {
|
else if (buffer) {
|
||||||
dc->drawScaledBitmap(buffer.get(), 0, 0, rect.w, rect.h);
|
dc->drawBitmap(0, 38, buffer.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,11 +83,18 @@ class ModelBitmapWidget: public Widget
|
|||||||
std::string filename = std::string(g_model.header.bitmap);
|
std::string filename = std::string(g_model.header.bitmap);
|
||||||
std::string fullpath = std::string(BITMAPS_PATH PATH_SEPARATOR) + filename;
|
std::string fullpath = std::string(BITMAPS_PATH PATH_SEPARATOR) + filename;
|
||||||
|
|
||||||
buffer.reset(BitmapBuffer::loadBitmap(fullpath.c_str()));
|
std::unique_ptr<BitmapBuffer> bitmap(BitmapBuffer::loadBitmap(fullpath.c_str()));
|
||||||
if (!buffer) {
|
if (!bitmap) {
|
||||||
TRACE("could not load bitmap '%s'", filename.c_str());
|
TRACE("could not load bitmap '%s'", filename.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!buffer || (buffer->width() != width()) || (buffer->height() != height())) {
|
||||||
|
buffer.reset(new BitmapBuffer(BMP_RGB565, width(), height()));
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer->clear(DEFAULT_BGCOLOR);
|
||||||
|
buffer->drawScaledBitmap(bitmap.get(), 0, 0, width(), height() - 38);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user