New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More efficient frame copying. #4
Conversation
@@ -28,7 +28,7 @@ Copyright (C) 2021 FreezeFrame | |||
|
|||
## Licenses For ImageSharp | |||
|
|||
- This tool uses [ImageSharp](https://sixlabors.com/products/imagesharp/), which requires a license for commercial use. | |||
- This tool uses [ImageSharp](https://sixlabors.com/products/imagesharp/), which requires a license for commercial support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
People can use the libraries commercially under the Apache license. They just can't ask me for any support unless they purchase a Six Labors license.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must be a line endings thing
Program.fs
Outdated
image.[x,y] <- source.[x,y] | ||
use gif = Image.Load(path) | ||
use image = new Image<Rgba32>(gif.Width, gif.Height) | ||
image.Frames.AddFrame(gif.Frames.RootFrame)|> ignore; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;
is optional in F# in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me two reads to figure out what you meant there! 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops :-)
@JimBobSquarePants left an MR here showing how stream copying would be done, per your comment. |
stream copying
This is awesome. Thanks so much! |
Just saw your tweet asking me for assistance with the ImageSharp API. This is my first time writing F# so I'm hoping I got it right!
I replaced the
[x, y]
frame iteration with a more efficient cloning. I also fixed the leak for the initial gif.I did spot something else but I'm not confident in my F# to do a fix.
I wouldn't return a byte array from the
getFrameFromGif
method, I'd return the stream and copy it to a filestream in order to remove the overhead of allocating and copying a new array for each time.