Hello,
I was wondering if there was a way to scale an image with SFML without any form of anti-aliasing. I'm not talking about turning anti-aliasing off for the window, but instead scaling an image so it doesn't look blurry.
I tried to write my own scale function to suit the purpose, but it always comes out as a white box covering the full image.
If someone could tell me if there's a function that does this, or what's wrong with my function, that would be great.
Thanks!
class AREA{
public:
Image img; //Area image
Sprite spr; //Area sprite
Color bnd_clr; //Boundary color
int x, y; //Image size
bool bnd[MAX_AREA_X][MAX_AREA_Y]; //Boundaries
}area[MAX_AREA];
bool spr_scale( int scale,
int index ){
//Create temporary variables
int atmp, btmp, ctmp, dtmp; //Temporary counter integers
Image tmp_img; //Temporary image
//Create temporary image
tmp_img.Create( area[index].x * scale, //Old image's x size * scale value
area[index].y * scale, //Old image's y size * scale value
Color(0, 0, 0) ); //Make the image 100% black
//Fill new image with scaled old image
for ( atmp = 1 ; atmp < area[index].y ; ++atmp ) //Original image y counter
for ( btmp = 1 ; btmp < area[index].x ; ++btmp ) //Original image x counter
for ( ctmp = 0 ; ctmp < scale ; ++ctmp ) //New image y counter
for ( dtmp = 0 ; dtmp < scale ; ++dtmp ) //New image x counter
//Set the pixel
tmp_img.SetPixel( ( btmp * scale ) + dtmp, //x position of pixel
( atmp * scale ) + ctmp, //y position of pixel
area[index].spr.GetPixel( btmp, atmp ) ); //Get old image color
//Set old image to the new scaled image
area[index].spr.Resize( ( area[index].x * scale ), //Set new x size...
( area[index].y * scale ) ); //...set new y size...
area[index].spr.SetImage( tmp_img ); //...and make it so
//Everything went alright
return true;
}