Bitmap fonts now use nearest neighbour scaling instead of xbrz
This commit is contained in:
1 parent
ee64928454
commit
35467039a7
4 files changed
+35
-30
No files matched your search
@@ -273,27 +273,7 @@ std::shared_ptr<ISharedImage> SDLImageShared::scaleInteger(int factor, SDL_Palet
|
||||
if (palette && surf->format->palette)
|
||||
SDL_SetSurfacePalette(surf, palette);
|
||||
|
||||
/// Convert current surface to ARGB format suitable for xBRZ
|
||||
/// TODO: skip its creation if this is format matches current surface (even if unlikely)
|
||||
SDL_Surface * intermediate = SDL_ConvertSurfaceFormat(surf, SDL_PIXELFORMAT_ARGB8888, 0);
|
||||
SDL_Surface * scaled = CSDL_Ext::newSurface(Point(surf->w * factor, surf->h * factor), intermediate);
|
||||
|
||||
assert(intermediate->pitch == intermediate->w * 4);
|
||||
assert(scaled->pitch == scaled->w * 4);
|
||||
|
||||
const uint32_t * srcPixels = static_cast<const uint32_t*>(intermediate->pixels);
|
||||
uint32_t * dstPixels = static_cast<uint32_t*>(scaled->pixels);
|
||||
|
||||
// avoid excessive granulation - xBRZ prefers at least 8-16 lines per task
|
||||
// TODO: compare performance and size of images, recheck values for potentially better parameters
|
||||
const int granulation = std::clamp(surf->h / 64 * 8, 8, 64);
|
||||
|
||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, intermediate->h, granulation), [factor, srcPixels, dstPixels, intermediate](const tbb::blocked_range<size_t> & r)
|
||||
{
|
||||
xbrz::scale(factor, srcPixels, dstPixels, intermediate->w, intermediate->h, xbrz::ColorFormat::ARGB, {}, r.begin(), r.end());
|
||||
});
|
||||
|
||||
SDL_FreeSurface(intermediate);
|
||||
SDL_Surface * scaled = CSDL_Ext::scaleSurfaceIntegerFactor(surf, factor, EScalingAlgorithm::XBRZ);
|
||||
|
||||
auto ret = std::make_shared<SDLImageShared>(scaled);
|
||||
|
||||
|
||||
Reference in new issue
Block a user