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

Author Topic: Image rotation  (Read 9576 times)

0 Members and 1 Guest are viewing this topic.

RokB

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Image rotation
« Reply #15 on: August 06, 2015, 02:32:18 pm »
RokB, re-arranging the pixels is computationally expensive. Transforming the getPixel() and setPixel() co-ordinates would be comparatively much faster. One problem with that approach is when you create a texture from that image. It looks like it would have to do the pixel re-arranging before/during that conversion.

Another problem would arise when using Image::copy() it seems, which is necessary for creating complex images. Personally, I think it would be a lot simpler to create a function rearranging the image rather than to go around tweaking everything that currently uses the class. I've already done so for my own use. It's not insanely expensive and it's not like it's the sort of thing you'd be using very often.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Image rotation
« Reply #16 on: August 06, 2015, 02:50:07 pm »
Personally, I think it would be a lot simpler to create a function rearranging the image rather than to go around tweaking everything that currently uses the class.
Nothing will break of course, it's just an internal optimization.

For simplicity, we can mark copy() and other operations so that they "evaluate" the image. Lazy evaluation loses a bit of its usefulness as such, with a bit of thought also this could be addressed.

One advantage that lazy evaluation definitely has is that it allows two subsequent transforms to be executed efficiently (O(1)). For example, it would then be enough to provide rotateCcw() and rotateCw() -- we wouldn't need a rotate180(), because twice 90° costs nothing.
« Last Edit: August 06, 2015, 02:54:25 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Hapax

  • Hero Member
  • *****
  • Posts: 3364
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Image rotation
« Reply #17 on: August 07, 2015, 03:54:36 pm »
we wouldn't need a rotate180(), because twice 90° costs nothing.
This is true and I'm sure it'd be perfectly acceptable. The only reason I mentioned a separate 180 degree rotation previously was because it can be optimised to be faster than 90.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything