Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Provide scaling for sf::Image  (Read 3822 times)

0 Members and 1 Guest are viewing this topic.

sharethis

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Provide scaling for sf::Image
« on: March 09, 2013, 03:14:59 pm »
I would like to see a simple scaling function for sf::Image. This could be done with simple linear or cubic interpolation. Later on there could be a parameter to control the algorithm.

At the moment it is a bit painful to juggle the raw pixel data around in order to perform this task yourself. There was a resize function in older versions of SFML already but that did not actually scale the image. Instead, it added a margin or cut off pixels from the image.

Such a basic task like image scaling should be provided by SFML in my opinion. Could you please give me feedback about this idea?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Provide scaling for sf::Image
« Reply #1 on: March 09, 2013, 03:21:54 pm »
Why would you need to scale images, rather than scale the entity that shows the final texture?
Laurent Gomila - SFML developer

sharethis

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Provide scaling for sf::Image
« Reply #2 on: March 09, 2013, 04:56:10 pm »
Why would you need to scale images, rather than scale the entity that shows the final texture?

I want to modify and create new images by copying and scaling them. So it's about basic image processing tasks. Since SFML provides a basic image class, it would be overkill to use a whole third-party image library.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Provide scaling for sf::Image
« Reply #3 on: March 09, 2013, 05:00:08 pm »
Quote
I want to modify and create new images by copying and scaling them.
But what's your goal? What do you want to achieve?
Laurent Gomila - SFML developer

sharethis

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Provide scaling for sf::Image
« Reply #4 on: March 09, 2013, 08:51:18 pm »
I use SFML as a full package for input, context, sound, image loading, and so on in my OpenGL application. My actual goal is a very special case. To avoid texture bleeding in my texture atlas, I want to manually generate mipmaps.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Provide scaling for sf::Image
« Reply #5 on: March 09, 2013, 09:07:10 pm »
Ok I see.

I'm not against this kind of feature, but it has a very low priority.
Laurent Gomila - SFML developer

void

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Provide scaling for sf::Image
« Reply #6 on: March 11, 2013, 01:27:32 pm »
Why would you need to scale images, rather than scale the entity that shows the final texture?
Software image scaling can offer much better quality then the bilinear hardware scaling fo sprite.
I run into the same problem. I wanted to have clear card images, with text and tiny details in them. Bilinear scaling made them look really bad.

I've used imagesampler http://code.google.com/p/imageresampler/ with modified input-output routines, as it's opensource and has no dependiencies.
Other libraries tend to pull a bunch of dependencies, and I don't want to link directly to libpngm libjpeg, when the SFML is linked to them anyway.
Using it however takes some overhead to convert data between SFML internal format and that supported by imagesampler.

I can paste examples, but you can see them yourself when you scale eg. a newspaper page, first with HW bilinear, and then with ImageMagic using cubic or lanczos.

Real-life usecase: As I scale the card image size to the screen size I resize them by software scaling, before using them as 1:1 sprites.

 

anything