GithubHelp home page GithubHelp logo

unable to rotate image? about flippy HOT 8 CLOSED

treeform avatar treeform commented on July 27, 2024
unable to rotate image?

from flippy.

Comments (8)

treeform avatar treeform commented on July 27, 2024 1

Oh I have figured it out. It was trimming the image incorrectly. I created a better trim function and will now use that.

0c1a9f9

Also added a test case for your error.

Thank you for reporting the bug!

from flippy.

teras avatar teras commented on July 27, 2024

I added before line 684 in flippy.nim the following code to debug it:

  echo $result & " -- " , 1+int((result.width - newWidth)/2) , " " , 1+int((result.height - newHeight)/2) , " " , newWidth , "/" , newHeight

I found that the problem is indeed with out of bounds numbers and the result is
<Image 50x51:4> -- 1 1 51/51
different values, I even have negative numbers, like for

var image = newImage(500,50,4)
echo image.rotate(20)

I get negative results
<Image 547x223:4> -- 166 -130 217/486

Should this happen?

from flippy.

treeform avatar treeform commented on July 27, 2024

There seems to be a bug with the rotate method. @benjif could you take a look?

from flippy.

teras avatar teras commented on July 27, 2024

Please excuse my comment.
I think the trim function is wrong.
It is good as a generic method, but not in this case.
What if an image is mostly "transparent", but only the center is painted?
Then rotation will minimize the image instead, not just rotate it.

IMHO the four edges of the rotated box should be calculated and crop the image accordingly.
Do you think we should discuss it more?

from flippy.

treeform avatar treeform commented on July 27, 2024

from flippy.

teras avatar teras commented on July 27, 2024

Maybe take into account something like this
https://gamedev.stackexchange.com/questions/86755/how-to-calculate-corner-positions-marks-of-a-rotated-tilted-rectangle

Find the location of the four points

  • (x,y)
  • (x+width, y)
  • (x+width,y+height)
  • (x,y+height)

and keep the min/max X and min/max Y as bounding box of the clipped area

from flippy.

treeform avatar treeform commented on July 27, 2024

Yes you are right. I will take a look.

from flippy.

treeform avatar treeform commented on July 27, 2024

I thing it was fixed by @guzba #16

from flippy.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.