mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
Added opacity change instead of blur for background image
This commit is contained in:
parent
1d8c607c15
commit
4040f58af6
@ -150,7 +150,7 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
|
||||
backgroundImage = QImage(blurredPic1PathQt);
|
||||
if (backgroundImage.isNull()) {
|
||||
QImage image(pic1Path);
|
||||
backgroundImage = m_game_list_utils.BlurImage(image, image.rect(), 16);
|
||||
backgroundImage = m_game_list_utils.ChangeImageOpacity(image, image.rect(), 0.5);
|
||||
|
||||
std::filesystem::path img_path =
|
||||
Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) /
|
||||
|
@ -177,7 +177,7 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
|
||||
backgroundImage = QImage(blurredPic1PathQt);
|
||||
if (backgroundImage.isNull()) {
|
||||
QImage image(pic1Path);
|
||||
backgroundImage = m_game_list_utils.BlurImage(image, image.rect(), 16);
|
||||
backgroundImage = m_game_list_utils.ChangeImageOpacity(image, image.rect(), 0.5);
|
||||
|
||||
std::filesystem::path img_path =
|
||||
Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) /
|
||||
|
@ -201,4 +201,29 @@ public:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QImage ChangeImageOpacity(const QImage& image, const QRect& rect, float opacity) {
|
||||
// Convert to ARGB32 format to ensure alpha channel support
|
||||
QImage result = image.convertToFormat(QImage::Format_ARGB32);
|
||||
|
||||
// Ensure opacity is between 0 and 1
|
||||
opacity = std::clamp(opacity, 0.0f, 1.0f);
|
||||
|
||||
// Convert opacity to integer alpha value (0-255)
|
||||
int alpha = static_cast<int>(opacity * 255);
|
||||
|
||||
// Process only the specified rectangle area
|
||||
for (int y = rect.top(); y <= rect.bottom(); ++y) {
|
||||
QRgb* line = reinterpret_cast<QRgb*>(result.scanLine(y));
|
||||
for (int x = rect.left(); x <= rect.right(); ++x) {
|
||||
// Get current pixel
|
||||
QRgb pixel = line[x];
|
||||
// Keep RGB values, but modify alpha while preserving relative transparency
|
||||
int newAlpha = (qAlpha(pixel) * alpha) / 255;
|
||||
line[x] = qRgba(qRed(pixel), qGreen(pixel), qBlue(pixel), newAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user