AuthorTopic: ROTSPRITE, useful tool  (Read 30696 times)

Offline Krice

  • 0001
  • *
  • Posts: 33
  • Karma: +0/-0
    • View Profile

Re: ROTSPRITE, useful tool

Reply #30 on: May 04, 2011, 12:25:58 pm
if the algorims is that simple i think it will be integrate sometime soon in the most used programs...

This went into my todo list for Brick Atelier. I hope it's simple enough to implement:)

Offline NickZA

  • 0001
  • *
  • Posts: 42
  • Karma: +0/-0
    • View Profile
    • Handcrafted Games

Re: ROTSPRITE, useful tool

Reply #31 on: July 24, 2011, 05:27:44 pm
You'll all have noticed that, as yet, there is no open release of implementation code for this, and so you don't see it in any common pixel tools.

The reason is that the approach is perhaps not as simple to decipher as the author, Xenowhirl, would make it appear. He glosses over the logic but doesn't describe the intent, which is more important when documenting an algorithm.

I managed to get Alan Paeth's "A Fast Algorithm for General Raster Rotation" running in about a day -- the shearing approach to rotation is much more amenable to a sane mind than approaching this through direct use of matrix math, or the sample-plot approach which leaves holes. My implementation doesn't do any blending, since the point is to try and avoid anything but the original colours used in the source image (which, AFAICT, is what RotSprite does).

Paeth's approach is not bad and very fast to process, but you will still the get the occasional "toothed jaggies" that are typically seen on aliased rotations (see OP). It is prior to this step that I would need to implement the entirety of something like RotSprite's approach -- the scaling part's already done, but it's the approach to smoothing (aliased smoothing, that is, i.e. no blending of neighbouring pixels) that I need to figure out, and also the approach Xenowhirl takes to resampling the expanded image using offsets, prior to pushing those back into a rotated image.

I think that it's enough to say, "Its been done by someone who wasn't a PhD in computational geometry," so it cannot be that hard to implement an alternative approach with as good or nearly as good results. It's more about recognising where rotated, aliased images tend to go wrong, and using code to fix those errors in the outputted image as a post-processing step. That's what I intend to try as my next step, anyway.

Offline SolarStrings

  • 0001
  • *
  • Posts: 24
  • Karma: +0/-0
    • View Profile

Re: ROTSPRITE, useful tool

Reply #32 on: August 22, 2011, 04:26:56 pm
Hi Guys!

I tried to implement this algorithm myself.
I integrated the code into my Map Editor for The Forgotten Planet ( http://theforgottenplanet.blogspot.com )

I'm using pretty much the same approach, but don't use any of the "mumbo-jumo" extra stuff he mentions where he describes the algorithm.

Here's the result:


(this alien on screen is the main character in the game ;) )

As you can see for your self, this result is quite ok, and looks very similar to the results his program produces.

Scaling to 8x then rotate and scale down to 1x was the best result in most cases. However, Small details are sometimes better preserved with the other conversions.
For example, If you look at the Image you can see that the eyes look better in some versions, then all you have to do is copy & paste the eye, and you're done.

Stand Alone Sprite rotater in this thread:

http://www.wayofthepixel.net/pixelation/index.php?topic=13052.0

- Linux Binary
- Windows Binary
- C Source Code (SDL)

SolarStrings
« Last Edit: August 25, 2011, 06:10:21 pm by SolarStrings »