Skip to content
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

Ability to flip and turn Fl_(RGB_)Images #56

Closed
darealshinji opened this issue Feb 11, 2020 · 6 comments
Closed

Ability to flip and turn Fl_(RGB_)Images #56

darealshinji opened this issue Feb 11, 2020 · 6 comments

Comments

@darealshinji
Copy link
Contributor

I would be interesting if there was a simple way to do horizontal and vertical flips on images and to turn them 90° to the left or right. This could for example be used to modify images of arrows. In theory it's just copying pixels in a different order, but I'm having my issues implementing such a thing.

@Albrecht-S
Copy link
Member

There are options to draw images flipped horiontally or vertically. This does not change the image in memory but can be useful. However, it's not possible to turn images 90°-wise. See documentation of arguments D and L of fl_draw_image().

Side note: many drawing functions can also be used with a transformation matrix, but I have no idea if this is applicable to drawing images. See chapter Drawing Things in FLTK.

That said, it's probably not the goal of FLTK to support image manipulations in memory. FLTK always tries to be F(ast) and L(ight) and this could be done in user code. Others may chime in with different opinions...

There are interesting articles (start here) describing how to access image pixels in memory, maybe this is what you're looking for?

@Albrecht-S
Copy link
Member

Addendum: see also Direct Image Drawing which states:

The behavior when drawing images when the current transformation matrix is not the identity is not defined, so you should only draw images when the matrix is set to the identity.

to clarify that image drawing is not usable with a transformation.

@erco77
Copy link
Contributor

erco77 commented Feb 11, 2020

I'd offer this type of thing, if popular (and probably is) might warrant a separate .lib file,
e.g. fltk_image_ops.lib

That'd keep the main library fast+light, while moving image ops to another lib.
However, that might be a slippery slope into 'lets re-implement imagemagick!'.
We could limit the image operations to simple stuff that doesn't involve calculating
subpixels and such, and just dumb operations like 90 degree turns.

But again, not sure we want to go down that path, we're not an image lib.. there's
other libs for that.

@Albrecht-S
Copy link
Member

But again, not sure we want to go down that path, we're not an image lib.. there's other libs for that.

Yep, after thinking about it, I'm really -1 on this. If we'd try to do it for Fl_RGB_Image's we'd certainly be asked to do it for other image types as well. Think of pixmaps, bitmaps, GIF images, ... This would be a never ending story ...

Please let's close this issue. @darealshinji ??

@darealshinji
Copy link
Contributor Author

Yes, okay. I think there's also one of these 1-header-libraries that provides stuff like this.

@darealshinji
Copy link
Contributor Author

Here's an example with a function I wrote that turns and flips Fl_RGB_Images: https://gist.github.com/darealshinji/a134365c76fc1258ded0118cb1dcd594
It also can handle different values for d() and ld(). It's Public Domain, if anyone wants to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants