- Added image caching system internally.

It would reduce memory usage in case that you use the same image file repeatedly on some meters. (Eg. Crop a part from same image by using ImageCrop.)
- Fixed an issue that Background image isn't drawn correctly when BackgroundMode=0 and tint option is set.
This commit is contained in:
spx
2011-03-08 19:39:04 +00:00
parent f19e76e6ec
commit 8ddc383ed1
3 changed files with 208 additions and 86 deletions

View File

@ -2122,23 +2122,26 @@ bool CMeterWindow::ResizeWindow(bool reset)
if (m_BackgroundMode == BGMODE_IMAGE)
{
PixelFormat format = tempBackground->GetPixelFormat();
if (format == PixelFormat32bppARGB)
{
format = PixelFormat32bppPARGB;
}
m_Background = tempBackground->Clone(0, 0, m_BackgroundSize.cx, m_BackgroundSize.cy, format);
w = m_BackgroundSize.cx;
h = m_BackgroundSize.cy;
}
else
{
w = max(w, m_BackgroundSize.cx);
h = max(h, m_BackgroundSize.cy);
}
Bitmap* background = new Bitmap(w, h, CTintedImage::AdjustNonAlphaPixelFormat(tempBackground));
Graphics graphics(background);
if (m_BackgroundMode == BGMODE_IMAGE)
{
Rect r(0, 0, w, h);
graphics.DrawImage(tempBackground, r, 0, 0, w, h, UnitPixel);
}
else
{
// Scale the background to fill the whole window
Bitmap* background = new Bitmap(w, h, PixelFormat32bppPARGB);
Graphics graphics(background);
if (m_BackgroundMode == BGMODE_SCALED_IMAGE)
{
const RECT m = m_BackgroundMargins;
@ -2210,10 +2213,10 @@ bool CMeterWindow::ResizeWindow(bool reset)
Rect r(0, 0, w, h);
graphics.DrawImage(tempBackground, r, 0, 0, w, h, UnitPixel, &imgAttr);
}
m_Background = background;
}
m_Background = background;
// Get the size form the background bitmap
m_WindowW = m_Background->GetWidth();
m_WindowH = m_Background->GetHeight();