This is a extension to apply the HQ2x/HQ3x/HQ4x algorithm with SFML images. The interface is pretty simple, with this methods:
namespace sfe {
using namespace sf;
// Initializes the HQx algorithm. Takes about one second and 64MB of RAM.
// This is called automatically by the methods below, if necessary.
inline void InitHQx();
// Receives a sf::Image and returns a 2-times bigger sf::Image, using the
// HQ2x magnification algorithm.
Image HQ2x(const Image& input);
// Receives a sf::Image and returns a 3-times bigger sf::Image, using the
// HQ3x magnification algorithm.
Image HQ3x(const Image& input);
// Receives a sf::Image and returns a 4-times bigger sf::Image, using the
// HQ4x magnification algorithm.
Image HQ4x(const Image& input);
}
Here's a code sample:
#include <SFML/Graphics.hpp>
#include <SFE/HQx.cpp>
int main() {
sf::Image img, hq2x, hq3x, hq4x;
img.LoadFromFile("test.png");
sfe::InitHQx(); // Unnecessary
hq2x = sfe::HQ2x(img);
hq2x.SaveToFile("hq2x.png");
hq3x = sfe::HQ3x(img);
hq3x.SaveToFile("hq3x.png");
hq4x = sfe::HQ4x(img);
hq4x.SaveToFile("hq4x.png");
return 0;
}
Samples: (HQ3x)
This is my first open-source code. I got the HQx code from
here, and I did some modifications in it to make it working with 32-bit colors. Also, don't try to use it with images that has some pixel with alpha channel other than 255.
Download link:
Click Here