SDL_RenderCopy scaling artifacts

Take two (on a new topic now) to see if I can get help.

I build a single 320x200 text in a pixel-specific way, and then I use SDL_RenderCopy to draw it at full window size.

However, it has stray pixels. See for example between the middle row of bricks here:

[Image: http://i.imgur.com/1Wisz3x.png ]

Is this expected behavior? I’ve tried setting hints, to no effect. Any recommendations?

tjpalmer wrote:

I’ve tried setting hints, to no effect. Any recommendations?

Are you sure you set hints before texture was created? Which hints did you try? Linear, nearest?------------------------
bigosaur.com

Hints should be set before texture is created. Afterwards it doesn’t matter.
What kind of artifacts? Can you upload a screenshot somewhere?

Pallav Nawani
IronCode Gaming Private Limited
Website: http://www.ironcode.com
Twitter: http://twitter.com/Ironcode_Gaming
Facebook: http://www.facebook.com/Ironcode.Gaming
Mobile: 9997478768On Wed, Mar 4, 2015 at 2:29 PM, mbabuskov <milan.babuskov at gmail.com> wrote:

tjpalmer wrote:

I’ve tried setting hints, to no effect. Any recommendations?

Are you sure you set hints before texture was created? Which hints did you
try? Linear, nearest?


bigosaur.com


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

tjpalmer wrote:

However, as I somewhat feared (though I still wanted to try it), this won’t help

Won’t or didn’t?

I using this for my game and it works fine. Perhaps there’s something wrong with alpha channel on your image or something like that (for example I discovered that some graphics programs create files with unexpected extra data in the alpha channel that can messup the way it looks on screen). How are you loading image, is it from PNG file? Does to problem also show up when you load from BMP or JPG?

If the problem is not visible in BMP/JPG then try fixing the PNG image. I recall have similar issues and just added a completely black layer behind the graphics, re-exported with Gimp and everything was fine afterwards. Also check if background color is saved in PNG.

Could you post the original image file that shows artifacts when scaled?------------------------
bigosaur.com

mbabuskov wrote:

Won’t or didn’t?

Didn’t achieve the effect I need. Default seems to be nearest (and is shown in my earlier screenshot), which is what I want, if not for the artifacts.

Here’s what I want (from my manual C++ scaling code), nearest sans artifacts:

[Image: http://i.imgur.com/Pz58lbI.png ]

And here is what linear does:

[Image: http://i.imgur.com/P49TTkY.png ]

mbabuskov wrote:

Are you sure you set hints before texture was created? Which hints did you try? Linear, nearest?

Thanks so much for the reply. I had missed the need to set it before the texture is created.

However, as I somewhat feared (though I still wanted to try it), this won’t help. Linear doesn’t have the stray pixels, but I really want nearest, because linear blurs. (Linear still has edge issues, too, at the very ends of the texture, although I think I know how to deal with that by putting a transparent edge in my texture.)

I’ve tried scaling manually myself on CPU now, too. It looks just right, but it’s too slow. (Current implementation is step by float, and truncate. Could look at optimizing.) I’ve considered all kinds of hacks (CPU scale to not full but still integer fraction of screen/window size, many other things, …), but maybe I should just bite the bullet and go to GL and shaders. That’s a bunch of extra work and learning curve, but I suspect I could get it to do the simple scaling that I want.

Any other easy fixes I should try first?

Can you post the code you’re using to render this?

Jonny DOn Wed, Mar 4, 2015 at 3:06 PM, tjpalmer wrote:

mbabuskov wrote:

Won’t or didn’t?

Didn’t achieve the effect I need. Default seems to be nearest (and is
shown in my earlier screenshot), which is what I want, if not for the
artifacts.

Here’s what I want (from my manual C++ scaling code), nearest sans
artifacts:

And here is what linear does:


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