Comments (8)
Oh I have figured it out. It was trimming the image incorrectly. I created a better trim function and will now use that.
Also added a test case for your error.
Thank you for reporting the bug!
from flippy.
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.
There seems to be a bug with the rotate method. @benjif could you take a look?
from flippy.
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.
from flippy.
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.
Yes you are right. I will take a look.
from flippy.
I thing it was fixed by @guzba #16
from flippy.
Related Issues (17)
- Float precision ? HOT 1
- Resizing Images using -d:useStl giving strange results HOT 2
- Incorrect color after minifying image HOT 2
- Flippy is not loading an image HOT 7
- Loops in flippy access memory discontinuously HOT 2
- Artifacts introduced when rendering subpixels HOT 2
- Can pictures be saved as memory files? HOT 2
- Getting an error when running the basic usage example: Error: undeclared identifier: 'rgba' HOT 2
- The 'image.save()' method can only be saved on a local disk. Can it be saved in memory? HOT 1
- Error: undeclared identifier: 'Rect' HOT 1
- Unnecessary param in computeBounds HOT 1
- flippy.nim(1, 22) Error: cannot open file: chroma/blends HOT 2
- Unable to build/install other libraries (e.g. NSU) that depends on flippy HOT 1
- STBI Exception HOT 5
- does not support Unicode filenames on Windows HOT 3
- image.putRgba issue or user error ? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flippy.