[GH-ISSUE #66] ImageOp.cpp -> FlipImage #39

Closed
opened 2026-05-05 03:35:38 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @lcineyes on GitHub (Mar 17, 2022).
Original GitHub issue: https://github.com/ultimatepp/ultimatepp/issues/66

Sorry, My English is very poor.

//ImageOp.cpp -> FlipImage
Image FlipImage(const Image& m, int mode)
{
return decode(mode,
FLIP_MIRROR_HORZ, MirrorHorz(m),
FLIP_ROTATE_180, Rotate180(m),
FLIP_MIRROR_VERT, MirrorVert(m),
FLIP_TRANSPOSE, Transpose(m),
FLIP_ROTATE_CLOCKWISE, RotateClockwise(m),
FLIP_TRANSVERSE, Transverse(m),
FLIP_ROTATE_ANTICLOCKWISE, RotateAntiClockwise(m),
m);
}

//Fh.h
template <class T, class V>
constexpr const V& decode(const T& sel, const V& def)
{
return def;
}

template <class T, class K, class V, typename... L>
constexpr V decode(const T& sel, const K& k, const V& v, const L& ...args)
{
return sel == k ? v : (V)decode(sel, args...);
}

In the FlipImage funciton, each conversion function is executed once before the mode hit.

Originally created by @lcineyes on GitHub (Mar 17, 2022). Original GitHub issue: https://github.com/ultimatepp/ultimatepp/issues/66 Sorry, My English is very poor. //ImageOp.cpp -> FlipImage Image FlipImage(const Image& m, int mode) { return decode(mode, FLIP_MIRROR_HORZ, MirrorHorz(m), FLIP_ROTATE_180, Rotate180(m), FLIP_MIRROR_VERT, MirrorVert(m), FLIP_TRANSPOSE, Transpose(m), FLIP_ROTATE_CLOCKWISE, RotateClockwise(m), FLIP_TRANSVERSE, Transverse(m), FLIP_ROTATE_ANTICLOCKWISE, RotateAntiClockwise(m), m); } //Fh.h template <class T, class V> constexpr const V& decode(const T& sel, const V& def) { return def; } template <class T, class K, class V, typename... L> constexpr V decode(const T& sel, const K& k, const V& v, const L& ...args) { return sel == k ? v : (V)decode(sel, args...); } In the FlipImage funciton, each conversion function is executed once before the mode hit.
Author
Owner

@kov-serg commented on GitHub (Mar 18, 2022):

Yes of course. To RotateAntiClockwise it calls all previous transformations and trash them.
I wounder why not to use simple switch instead this crutches?

<!-- gh-comment-id:1072057202 --> @kov-serg commented on GitHub (Mar 18, 2022): Yes of course. To [RotateAntiClockwise](https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/Draw/ImageOp.cpp#L748) it calls all previous transformations and trash them. I wounder why not to use simple switch instead this crutches?
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/ultimatepp#39
No description provided.