mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Added "ImageAlpha" option to the IMAGE meter.
Changed the interpolation mode in AntiAlias=1 to Default from Bicubic. There is a possibility that this change will be changed again in the future.
This commit is contained in:
parent
0bcd8c30fc
commit
16b1918af3
@ -419,7 +419,8 @@ bool CMeter::Draw(Graphics& graphics)
|
|||||||
|
|
||||||
if (m_AntiAlias)
|
if (m_AntiAlias)
|
||||||
{
|
{
|
||||||
graphics.SetInterpolationMode(InterpolationModeBicubic);
|
//graphics.SetInterpolationMode(InterpolationModeBicubic); // Bicubic is not suitable for shrinking an image.
|
||||||
|
graphics.SetInterpolationMode(InterpolationModeDefault);
|
||||||
graphics.SetSmoothingMode(SmoothingModeHighQuality);
|
graphics.SetSmoothingMode(SmoothingModeHighQuality);
|
||||||
graphics.SetPixelOffsetMode(PixelOffsetModeHighQuality);
|
graphics.SetPixelOffsetMode(PixelOffsetModeHighQuality);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ CMeterImage::CMeterImage(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
|||||||
m_WidthDefined = false;
|
m_WidthDefined = false;
|
||||||
m_HeightDefined = false;
|
m_HeightDefined = false;
|
||||||
m_PreserveAspectRatio = false;
|
m_PreserveAspectRatio = false;
|
||||||
|
m_ImageAlpha = 255;
|
||||||
m_hBuffer = NULL;
|
m_hBuffer = NULL;
|
||||||
m_Modified.dwHighDateTime = 0;
|
m_Modified.dwHighDateTime = 0;
|
||||||
m_Modified.dwLowDateTime = 0;
|
m_Modified.dwLowDateTime = 0;
|
||||||
@ -205,7 +206,7 @@ void CMeterImage::ReadConfig(const WCHAR* section)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_Measure)
|
if (!m_Initialized || !m_Measure)
|
||||||
{
|
{
|
||||||
std::wstring oldImageName = m_ImageName;
|
std::wstring oldImageName = m_ImageName;
|
||||||
|
|
||||||
@ -220,6 +221,10 @@ void CMeterImage::ReadConfig(const WCHAR* section)
|
|||||||
|
|
||||||
m_PreserveAspectRatio = 0!=parser.ReadInt(section, L"PreserveAspectRatio", 0);
|
m_PreserveAspectRatio = 0!=parser.ReadInt(section, L"PreserveAspectRatio", 0);
|
||||||
|
|
||||||
|
m_ImageAlpha = parser.ReadInt(section, L"ImageAlpha", 255);
|
||||||
|
m_ImageAlpha = min(255, m_ImageAlpha);
|
||||||
|
m_ImageAlpha = max(0, m_ImageAlpha);
|
||||||
|
|
||||||
if (-1 != (int)parser.ReadFormula(section, L"W", -1))
|
if (-1 != (int)parser.ReadFormula(section, L"W", -1))
|
||||||
{
|
{
|
||||||
m_WidthDefined = true;
|
m_WidthDefined = true;
|
||||||
@ -316,8 +321,30 @@ bool CMeterImage::Draw(Graphics& graphics)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rect r(x, y, drawW, drawH);
|
Rect r(x, y, drawW, drawH);
|
||||||
|
|
||||||
|
if (m_ImageAlpha == 255)
|
||||||
|
{
|
||||||
graphics.DrawImage(m_Bitmap, r, 0, 0, imageW, imageH, UnitPixel);
|
graphics.DrawImage(m_Bitmap, r, 0, 0, imageW, imageH, UnitPixel);
|
||||||
}
|
}
|
||||||
|
else if (m_ImageAlpha > 0)
|
||||||
|
{
|
||||||
|
REAL alp = m_ImageAlpha / 255.0f;
|
||||||
|
|
||||||
|
// Initialize the color matrix
|
||||||
|
ColorMatrix colorMatrix = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 0.0f, alp, 0.0f,
|
||||||
|
0.0f, 0.0f, 0.0f, 0.0f, 1.0f };
|
||||||
|
|
||||||
|
// Create an ImageAttributes object and set its color matrix
|
||||||
|
ImageAttributes imageAtt;
|
||||||
|
imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
|
||||||
|
|
||||||
|
// Draw the semi-transparent bitmap image
|
||||||
|
graphics.DrawImage(m_Bitmap, r, 0, 0, imageW, imageH, UnitPixel, &imageAtt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ private:
|
|||||||
bool m_WidthDefined;
|
bool m_WidthDefined;
|
||||||
bool m_HeightDefined;
|
bool m_HeightDefined;
|
||||||
bool m_PreserveAspectRatio; // If true, aspect ratio of the image is preserved when the image is scaled
|
bool m_PreserveAspectRatio; // If true, aspect ratio of the image is preserved when the image is scaled
|
||||||
|
int m_ImageAlpha; // Transparency value 0 - 255
|
||||||
HGLOBAL m_hBuffer;
|
HGLOBAL m_hBuffer;
|
||||||
FILETIME m_Modified;
|
FILETIME m_Modified;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user