Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Toolbars #1217

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/mpc-hc/ImageGrayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,20 @@ bool ImageGrayer::UpdateColor(const CImage& imgSource, CImage& imgDest, bool dis

return true;
}

void ImageGrayer::PreMultiplyAlpha(CImage& imgSource) {
BYTE* bits = static_cast<BYTE*>(imgSource.GetBits());
for (int y = 0; y < imgSource.GetHeight(); y++, bits += imgSource.GetPitch()) {
RGBQUAD* p = reinterpret_cast<RGBQUAD*>(bits);
for (int x = 0; x < imgSource.GetWidth(); x++) {
HLS hls(p[x]);

RGBQUAD rgb = hls.toRGBQUAD();

p[x].rgbRed = static_cast<BYTE>(round((float)p[x].rgbRed * p[x].rgbReserved / 255.0f));
p[x].rgbBlue = static_cast<BYTE>(round((float)p[x].rgbBlue * p[x].rgbReserved / 255.0f));
p[x].rgbGreen = static_cast<BYTE>(round((float)p[x].rgbGreen * p[x].rgbReserved / 255.0f));
}
}
}

1 change: 1 addition & 0 deletions src/mpc-hc/ImageGrayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ namespace ImageGrayer

bool Gray(const CImage& imgSource, CImage& imgDest, float brightness = 1.0f);
bool UpdateColor(const CImage& imgSource, CImage& imgDest, bool disabled, mpcColorStyle colorStyle);
void PreMultiplyAlpha(CImage& imgSource);
}
8 changes: 6 additions & 2 deletions src/mpc-hc/PlayerToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "SVGImage.h"
#include "ImageGrayer.h"
#include "CMPCTheme.h"
#include "Gdiplusimaging.h"

// CPlayerToolBar

Expand Down Expand Up @@ -176,8 +177,11 @@ void CPlayerToolBar::LoadToolbarImage()
targetDC.SelectObject(CBitmap::FromHandle(volumeOff));
targetDC.BitBlt(0, 0, height * 2, height, &sourceDC, volumeIndex * height, imageDisabledOffset, SRCCOPY);

//volumeOn.Save(_T("c:\\temp\\vON.bmp"));
//volumeOff.Save(_T("c:\\temp\\vOFF.bmp"));
volumeOn.Save(L"c:\\temp\\vON.png", Gdiplus::ImageFormatPNG);
adipose marked this conversation as resolved.
Show resolved Hide resolved
volumeOff.Save(L"c:\\temp\\vOFF.png", Gdiplus::ImageFormatPNG);

ImageGrayer::PreMultiplyAlpha(volumeOn);
ImageGrayer::PreMultiplyAlpha(volumeOff);

sourceDC.SelectObject(pOldSourceBmp);
targetDC.SelectObject(pOldTargetBmp);
Expand Down
4 changes: 2 additions & 2 deletions src/mpc-hc/VolumeCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ void CVolumeCtrl::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
if (drOn.Width() > 0) {
src = drOn;
src.OffsetRect(-src.TopLeft());
vOn.Draw(dcMem, drOn, src);
vOn.AlphaBlend(dcMem, drOn, src);
}
drOff = dr;
drOff.left = drOn.right;
if (drOff.Width() > 0) {
src = drOff;
src.OffsetRect(-src.TopLeft());
src.OffsetRect(drOn.right-drOn.left, 0);
vOff.Draw(dcMem, drOff, src);
vOff.AlphaBlend(dcMem, drOff, src);
}
}
CMPCThemeUtil::flushMemDC(&dc, dcMem, memRect);
Expand Down