-
Notifications
You must be signed in to change notification settings - Fork 102
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
Add dmi_resize_png using the image crate #39
Conversation
Thanks for the PR, and welcome aboard 👍 |
Have you done any tests of how fast this is compared to http://www.byond.com/docs/ref/info.html#/icon/proc/Scale ? |
What's the use case here ? |
@AnturK @SpaceManiac The point of this is that Scale() has this little caveat: |
Like, if anyone knows what the rhyme or reason to Scale() occasionally just deciding to apply bilinear antialiasing and how to prevent it from doing that, I'd be happy to implement my icon upscaling with native BYOND procs. This idea came up while working with the spritesheet asset datum and needing to upscale a spritesheet for a UI. |
You probably don't have |
Yeah, it's direct /icon modification that matters. |
Hrm. Can someone help me with this? Even after reading through the rust error handling guidelines, I can't figure out how to implement non-panick file read/write, as the image library returns ImageError instead of Error and there's no type conversion defined for "ImageError -> Error". |
Well it was an adventure, but with PJB's help |
d399f41
to
35a0be4
Compare
@ShadowLarkens new conflicts |
35a0be4
to
2e3cf13
Compare
@spookydonut Resolved, let me know if there's anything I need to change to follow #42 |
@aspenluxxxy |
src/dmi.rs
Outdated
} | ||
} | ||
|
||
fn resize_png(path: &str, width: &str, height: &str) -> std::result::Result<(), ResizePngError> { |
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.
fn resize_png(path: &str, width: &str, height: &str) -> std::result::Result<(), ResizePngError> { | |
fn resize_png<P: AsRef<Path>>(path: P, width: u32, height: u32) -> std::result::Result<(), Error> { |
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.
Can BYOND call functions with u32 arguments? I thought it explicitly only worked with strings
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.
Correct, but you'd convert them to u32 in the byond_fn!
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.
Trying to do that results in the ?
no longer working for the ParseIntErrors because byond_fn! doesn't actually return a Result (Or something like that?)
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.
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.
Please fix the merge conflict
Tweak from panic to error return Finally fix the resize_png fn (Oh god thank you PJB3005) Allow user to pick resize mode, use rust_g::Error instead of custom enum
19f9367
to
d0ce5a0
Compare
@Cyberboss Done |
Please be gentle this is literally the first time I've ever touched rust ;w;
I am probably going to be absolutely helpless if this needs any optimization or tweaks to file writing