Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions src/reshade_effect_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@

#include <stb_image.h>
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#if __has_include(<stb_image_resize2.h>)
#include <stb_image_resize2.h>
#else
#include <stb_image_resize.h>
#endif

#include <mutex>
#include <unistd.h>
Expand Down Expand Up @@ -1150,7 +1154,13 @@ bool ReshadeEffectPipeline::init(CVulkanDevice *device, const ReshadeEffectKey &
if (w != (int)texture->width() || h != (int)texture->height())
{
resized_data.resize(texture->width() * texture->height() * 4);
#if __has_include(<stb_image_resize2.h>)
// stb_image_resize2 renames stbir_resize_uint8 to stbir_resize_uint8_linear
// (stbir_resize_uint8_srgb is the gamma-aware variant).
stbir_resize_uint8_linear(data, w, h, 0, resized_data.data(), texture->width(), texture->height(), 0, STBIR_RGBA);
#else
stbir_resize_uint8(data, w, h, 0, resized_data.data(), texture->width(), texture->height(), 0, STBI_rgb_alpha);
#endif

w = texture->width();
h = texture->height();
Expand Down
12 changes: 12 additions & 0 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ static const int g_nBaseCursorScale = 36;
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image.h>
#include <stb_image_write.h>
#if __has_include(<stb_image_resize2.h>)
#include <stb_image_resize2.h>
#else
#include <stb_image_resize.h>
#endif

#define GPUVIS_TRACE_IMPLEMENTATION
#include "gpuvis_trace_utils.h"
Expand Down Expand Up @@ -1789,9 +1793,17 @@ bool MouseCursor::getTexture()
}
}
std::vector<uint32_t> resizeBuffer( nDesiredWidth * nDesiredHeight );
#if __has_include(<stb_image_resize2.h>)
// stb_image_resize2 replaces (num_channels=4, alpha_channel=3,
// STBIR_FLAG_ALPHA_PREMULTIPLIED) with a single STBIR_RGBA_PM enum.
stbir_resize_uint8_srgb( (unsigned char *)pixels.data(), image->width, image->height, 0,
(unsigned char *)resizeBuffer.data(), nDesiredWidth, nDesiredHeight, 0,
STBIR_RGBA_PM );
#else
stbir_resize_uint8_srgb( (unsigned char *)pixels.data(), image->width, image->height, 0,
(unsigned char *)resizeBuffer.data(), nDesiredWidth, nDesiredHeight, 0,
4, 3, STBIR_FLAG_ALPHA_PREMULTIPLIED );
#endif

cursorBuffer = std::vector<uint32_t>(surfaceWidth * surfaceHeight);
for (int i = 0; i < nDesiredHeight; i++)
Expand Down