mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Code cleanup.
This commit is contained in:
parent
cecd111869
commit
8339d22a0f
@ -2441,7 +2441,7 @@ bool CMeterWindow::ResizeWindow(bool reset)
|
|||||||
h = max(h, m_BackgroundSize.cy);
|
h = max(h, m_BackgroundSize.cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap* background = new Bitmap(w, h, CTintedImage::AdjustNonAlphaPixelFormat(tempBackground));
|
Bitmap* background = new Bitmap(w, h, PixelFormat32bppPARGB);
|
||||||
Graphics graphics(background);
|
Graphics graphics(background);
|
||||||
|
|
||||||
if (m_BackgroundMode == BGMODE_IMAGE)
|
if (m_BackgroundMode == BGMODE_IMAGE)
|
||||||
@ -2503,6 +2503,7 @@ bool CMeterWindow::ResizeWindow(bool reset)
|
|||||||
Rect r(0, h - m.bottom, m.left, m.bottom);
|
Rect r(0, h - m.bottom, m.left, m.bottom);
|
||||||
graphics.DrawImage(tempBackground, r, 0, m_BackgroundSize.cy - m.bottom, m.left, m.bottom, UnitPixel);
|
graphics.DrawImage(tempBackground, r, 0, m_BackgroundSize.cy - m.bottom, m.left, m.bottom, UnitPixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bottom
|
// Bottom
|
||||||
Rect r(m.left, h - m.bottom, w - m.left - m.right, m.bottom);
|
Rect r(m.left, h - m.bottom, w - m.left - m.right, m.bottom);
|
||||||
graphics.DrawImage(tempBackground, r, m.left, m_BackgroundSize.cy - m.bottom, m_BackgroundSize.cx - m.left - m.right, m.bottom, UnitPixel);
|
graphics.DrawImage(tempBackground, r, m.left, m_BackgroundSize.cy - m.bottom, m_BackgroundSize.cx - m.left - m.right, m.bottom, UnitPixel);
|
||||||
|
@ -28,7 +28,7 @@ using namespace Gdiplus;
|
|||||||
class ImageCache
|
class ImageCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ImageCache(Bitmap* bitmap, HGLOBAL hBuffer) : m_Bitmap(bitmap), m_hBuffer(hBuffer), m_Ref(1) {}
|
ImageCache(Bitmap* bitmap) : m_Bitmap(bitmap), m_Ref(1) {}
|
||||||
~ImageCache() { Dispose(); }
|
~ImageCache() { Dispose(); }
|
||||||
|
|
||||||
void AddRef() { ++m_Ref; }
|
void AddRef() { ++m_Ref; }
|
||||||
@ -42,10 +42,9 @@ private:
|
|||||||
ImageCache() {}
|
ImageCache() {}
|
||||||
ImageCache(const ImageCache& cache) {}
|
ImageCache(const ImageCache& cache) {}
|
||||||
|
|
||||||
void Dispose() { delete m_Bitmap; m_Bitmap = NULL; if (m_hBuffer) { ::GlobalFree(m_hBuffer); m_hBuffer = NULL; } }
|
void Dispose() { delete m_Bitmap; m_Bitmap = NULL; }
|
||||||
|
|
||||||
Bitmap* m_Bitmap;
|
Bitmap* m_Bitmap;
|
||||||
HGLOBAL m_hBuffer;
|
|
||||||
int m_Ref;
|
int m_Ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -240,7 +239,7 @@ Bitmap* CTintedImage::LoadImageFromFileHandle(HANDLE fileHandle, DWORD fileSize,
|
|||||||
hBuffer = NULL;
|
hBuffer = NULL;
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
*ppCache = new ImageCache(bitmap, hBuffer);
|
*ppCache = new ImageCache(bitmap);
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,7 +379,7 @@ void CTintedImage::ApplyCrop()
|
|||||||
{
|
{
|
||||||
if (m_Crop.Width == 0 || m_Crop.Height == 0)
|
if (m_Crop.Width == 0 || m_Crop.Height == 0)
|
||||||
{
|
{
|
||||||
m_BitmapTint = new Bitmap(0, 0, PixelFormat24bppRGB); // create dummy bitmap
|
m_BitmapTint = new Bitmap(0, 0, PixelFormat32bppPARGB); // create dummy bitmap
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -419,8 +418,7 @@ void CTintedImage::ApplyCrop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rect r(0, 0, m_Crop.Width, m_Crop.Height);
|
Rect r(0, 0, m_Crop.Width, m_Crop.Height);
|
||||||
m_BitmapTint = new Bitmap(r.Width, r.Height,
|
m_BitmapTint = new Bitmap(r.Width, r.Height, PixelFormat32bppPARGB);
|
||||||
AdjustNonAlphaPixelFormat(m_Bitmap, x >= 0 && y >= 0 && (x + m_Crop.Width) <= imageW && (y + m_Crop.Height) <= imageH));
|
|
||||||
|
|
||||||
Graphics graphics(m_BitmapTint);
|
Graphics graphics(m_BitmapTint);
|
||||||
graphics.DrawImage(m_Bitmap, r, x, y, r.Width, r.Height, UnitPixel);
|
graphics.DrawImage(m_Bitmap, r, x, y, r.Width, r.Height, UnitPixel);
|
||||||
@ -489,7 +487,7 @@ Bitmap* CTintedImage::TurnGreyscale(Bitmap* source)
|
|||||||
|
|
||||||
// We need a blank bitmap to paint our greyscale to in case of alpha
|
// We need a blank bitmap to paint our greyscale to in case of alpha
|
||||||
Rect r(0, 0, source->GetWidth(), source->GetHeight());
|
Rect r(0, 0, source->GetWidth(), source->GetHeight());
|
||||||
Bitmap* bitmap = new Bitmap(r.Width, r.Height, AdjustNonAlphaPixelFormat(source));
|
Bitmap* bitmap = new Bitmap(r.Width, r.Height, PixelFormat32bppPARGB);
|
||||||
|
|
||||||
Graphics graphics(bitmap);
|
Graphics graphics(bitmap);
|
||||||
graphics.DrawImage(source, r, 0, 0, r.Width, r.Height, UnitPixel, &ImgAttr);
|
graphics.DrawImage(source, r, 0, 0, r.Width, r.Height, UnitPixel, &ImgAttr);
|
||||||
@ -551,7 +549,7 @@ void CTintedImage::ApplyTransform()
|
|||||||
Bitmap* original = GetImage();
|
Bitmap* original = GetImage();
|
||||||
|
|
||||||
Rect r(0, 0, original->GetWidth(), original->GetHeight());
|
Rect r(0, 0, original->GetWidth(), original->GetHeight());
|
||||||
Bitmap* transform = new Bitmap(r.Width, r.Height, AdjustNonAlphaPixelFormat(original));
|
Bitmap* transform = new Bitmap(r.Width, r.Height, PixelFormat32bppPARGB);
|
||||||
|
|
||||||
Graphics graphics(transform);
|
Graphics graphics(transform);
|
||||||
|
|
||||||
|
@ -85,9 +85,6 @@ public:
|
|||||||
void DisposeImage();
|
void DisposeImage();
|
||||||
void LoadImage(const std::wstring& imageName, bool bLoadAlways);
|
void LoadImage(const std::wstring& imageName, bool bLoadAlways);
|
||||||
|
|
||||||
static Gdiplus::PixelFormat AdjustNonAlphaPixelFormat(Gdiplus::Bitmap* bitmap, bool additionalCondition = true)
|
|
||||||
{ return (bitmap->GetPixelFormat() == PixelFormat24bppRGB && additionalCondition) ? PixelFormat24bppRGB : PixelFormat32bppPARGB; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum CROPMODE
|
enum CROPMODE
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user