SDL 1.3 image scaling

Hi Folks

I’m scaling an image from 1024x768 to 1280x1024, and the result looks like a car crash. It’s all pixellated and horrible, whereas if I scale it in Fireworks/GIMP etc it looks OK.

I see a comment that “SDL_TEXTURESCALEMODE_FAST is the only type supported at this time” and the SDL source seems to confirm it.

Is there any way to get it better? I am using DirectX - what about GDI or something??

Any help much appreciated!

Thanks
Ed

Well that’s odd… It looks like the code in D3D_RenderCopy actually supports
different scale modes, but D3D_SetTextureScaleMode doesn’t actually support
setting the mode! You ought to write up a patch for it.________________________________
From: e_byard@yahoo.co.uk (Edward Byard)
Subject: [SDL] SDL 1.3 image scaling

Hi Folks

I’m scaling an image from 1024x768 to 1280x1024, and the result looks like a car
crash. It’s all pixellated and horrible, whereas if I scale it in Fireworks/GIMP
etc it looks OK.

I see a comment that “SDL_TEXTURESCALEMODE_FAST is the only type supported at
this time” and the SDL source seems to confirm it.

Is there any way to get it better? I am using DirectX - what about GDI or
something??

Any help much appreciated!

Thanks
Ed

Actually, nevermind. I was reading the code wrong. It looks like these
different modes are supported. Maybe they just don’t do all that much under
D3D. Try using the GL renderer and see if it looks any better.________________________________
From: @Mason_Wheeler (Mason Wheeler)
Subject: Re: [SDL] SDL 1.3 image scaling

Well that’s odd… It looks like the code in D3D_RenderCopy actually supports
different scale modes, but D3D_SetTextureScaleMode doesn’t actually support
setting the mode! You ought to write up a patch for it.


From: e_byard@yahoo.co.uk (Edward Byard)
Subject: [SDL] SDL 1.3 image scaling

Hi Folks

I’m scaling an image from 1024x768 to 1280x1024, and the result looks like a car
crash. It’s all pixellated and horrible, whereas if I scale it in Fireworks/GIMP
etc it looks OK.

I see a comment that “SDL_TEXTURESCALEMODE_FAST is the only type supported at
this time” and the SDL source seems to confirm it.

Is there any way to get it better? I am using DirectX - what about GDI or
something??

Any help much appreciated!

Thanks
Ed

Also, if it’s an image you have outside the program (like a png or bmp), and
you know you’ll have to scale it, you could just scale it outside the
program with GIMP, if all else fails. If it’s being scaled on a
per-computer basis, then you might want to look into what other modes are
supported (you might have to grab the latest repository version?).

Take care,
-AlexOn Wed, Dec 22, 2010 at 2:42 PM, Mason Wheeler wrote:

Actually, nevermind. I was reading the code wrong. It looks like these
different modes are supported. Maybe they just don’t do all that much under
D3D. Try using the GL renderer and see if it looks any better.


From: Mason Wheeler
**Subject: Re: [SDL] SDL 1.3 image scaling

Well that’s odd… It looks like the code in D3D_RenderCopy actually
supports different scale modes, but D3D_SetTextureScaleMode doesn’t actually
support setting the mode! You ought to write up a patch for it.


From: ebyard <e_byard at yahoo.co.uk>
**Subject: [SDL] SDL 1.3 image scaling

Hi Folks

I’m scaling an image from 1024x768 to 1280x1024, and the result looks like
a car crash. It’s all pixellated and horrible, whereas if I scale it in
Fireworks/GIMP etc it looks OK.

I see a comment that “SDL_TEXTURESCALEMODE_FAST is the only type supported
at this time” and the SDL source seems to confirm it.

Is there any way to get it better? I am using DirectX - what about GDI or
something??

Any help much appreciated!

Thanks
Ed


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Ed,

I’ve been using SDL 1.3 and have had no problem scaling images. The only
thing I do is call RenderCopy with the size I want it scaled to in the DEST
Rect.

What format is your image in? 16 bit, 24, 32? Do you have a sample to show
the problem?From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Alex Barry
Sent: Wednesday, December 22, 2010 6:06 PM
To: SDL Development List
Subject: Re: [SDL] SDL 1.3 image scaling

Also, if it’s an image you have outside the program (like a png or bmp), and
you know you’ll have to scale it, you could just scale it outside the
program with GIMP, if all else fails. If it’s being scaled on a
per-computer basis, then you might want to look into what other modes are
supported (you might have to grab the latest repository version?).

Take care,
-Alex

On Wed, Dec 22, 2010 at 2:42 PM, Mason Wheeler wrote:

Actually, nevermind. I was reading the code wrong. It looks like these
different modes are supported. Maybe they just don’t do all that much under
D3D. Try using the GL renderer and see if it looks any better.


From: masonwheeler@yahoo.com (Mason Wheeler)
Subject: Re: [SDL] SDL 1.3 image scaling

Well that’s odd… It looks like the code in D3D_RenderCopy actually
supports different scale modes, but D3D_SetTextureScaleMode doesn’t actually
support setting the mode! You ought to write up a patch for it.


From: e_byard@yahoo.co.uk (Edward Byard)
Subject: [SDL] SDL 1.3 image scaling

Hi Folks

I’m scaling an image from 1024x768 to 1280x1024, and the result looks like a
car crash. It’s all pixellated and horrible, whereas if I scale it in
Fireworks/GIMP etc it looks OK.

I see a comment that “SDL_TEXTURESCALEMODE_FAST is the only type supported
at this time” and the SDL source seems to confirm it.

Is there any way to get it better? I am using DirectX - what about GDI or
something??

Any help much appreciated!

Thanks
Ed


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi

Yeah I have done the same, here’s some test code. I’d be interested to see what happens on your system.

Code:

#include “SDL.h”
#include “SDL_image.h”
#include <stdio.h>

int wmain(int argc, char *argv[])
{
int numdisplays, defaultdisplay, i;
int nummodes, j;
int * scalemode;
SDL_TextureScaleMode scaleMode = SDL_TEXTURESCALEMODE_FAST;
SDL_BlendMode blendMode = SDL_BLENDMODE_BLEND;

SDL_Surface *testImg;
SDL_Rect srcRect,dstRect;
SDL_Texture *testTxu;

SDL_DisplayMode mode;

srcRect.w = 1024;
srcRect.h = 768;

if (SDL_Init(SDL_INIT_VIDEO) != 0) 
{
	printf("Error initializing SDL: ");
	return 1;
}

// IMG_Init(IMG_INIT_BMP);
Uint32 ticks = SDL_GetTicks();
testImg = IMG_Load(“test.bmp”); // is a 24 bit BMP but same happens with a 32 bit PNG…
printf("Load time = %ld mS ",SDL_GetTicks() - ticks);
if (testImg == NULL)
{
printf(“Error loading file %s”,IMG_GetError());
return 1;
}
// SDL_DisplayFormat(testImg);

atexit(SDL_Quit);

SDL_SelectVideoDisplay(0);
SDL_Window *window1 = SDL_CreateWindow("Window 1",0,0,1280,1024,SDL_WINDOW_SHOWN|SDL_WINDOW_MAXIMIZED);
SDL_CreateRenderer(window1,-1,SDL_RENDERER_SINGLEBUFFER); // used to use hardware accel - should turn it back on!
SDL_SelectRenderer(window1);

SDL_SelectVideoDisplay(1);
SDL_Window *window2 = SDL_CreateWindow("Window 2",0,0,1280,1024,SDL_WINDOW_SHOWN|SDL_WINDOW_MAXIMIZED);
SDL_CreateRenderer(window2,-1,SDL_RENDERER_SINGLEBUFFER);
SDL_SelectRenderer(window2);

srcRect.x = 0;
srcRect.y = 0;
dstRect.x = dstRect.y = 0;

dstRect.w = 1280;
dstRect.h = 1024;

for (i=0;i<2;i++)
{
	SDL_SelectVideoDisplay(i);

	if (i==0)	// There seems to be a bug in SDL where SDL_GetCurrentVideoDisplay always returns 0 so have to use this for now!
		SDL_SelectRenderer(window1);
	else
		SDL_SelectRenderer(window2);

	testTxu = SDL_CreateTextureFromSurface(0,testImg);
	SDL_SetTextureScaleMode(testTxu,scaleMode);
	SDL_SetTextureBlendMode(testTxu,blendMode);
	SDL_RenderClear(); /* clear the screen */
	ticks = SDL_GetTicks();
	SDL_RenderCopy(testTxu,&srcRect,&dstRect); /* render the area of the texture defined by textureRegion (use NULL for the full thing) */
	printf("Render time = %ld mS \r\n",SDL_GetTicks() - ticks);
	SDL_RenderPresent(); /* update the screen */
}
SDL_Delay(5000);
SDL_FreeSurface(testImg);

IMG_Quit();
SDL_DestroyWindow(window1);
SDL_DestroyWindow(window2);
return 0;

}

I’m using source version 4904 (downloaded from the main SDL website) - something tells me this is a bit out of date??

I just checked the mercurial repository and it looks like there’s been some changes in that area. I might update first of all.

Scrap that - there are no differences. Back to square 1!