UI: Image Rotate #117352

Merged
Harley Acheson merged 10 commits from Harley/blender:ImageRotate into main 2024-01-31 23:36:37 +01:00
Member

Operator to rotate images in 90 degree increments.


This PR changes the "Flip" menu to "Transform" and adds options to rotate the image by 90 degrees clockwise, 90 counter-clockwise, and 180 degrees.

image

Operator to rotate images in 90 degree increments. --- This PR changes the "Flip" menu to "Transform" and adds options to rotate the image by 90 degrees clockwise, 90 counter-clockwise, and 180 degrees. ![image](/attachments/88e90d22-f5bc-473c-a166-ceb81ea7cb27)
Harley Acheson added 1 commit 2024-01-20 04:50:50 +01:00
02d9c2b8be UI: Image Rotate
Operator to rotate images in 90 degree increments.
Harley Acheson changed title from UI: Image Rotate to WIP: UI: Image Rotate 2024-01-20 04:52:43 +01:00
Harley Acheson added this to the User Interface project 2024-01-20 04:54:02 +01:00

I think IMB_transform could be used for this, even if it's somewhat overkill. You would get multi-threading "for free" though.

If not that, I think factoring out the actual rotation function into separate piece of code would be good. Like there already exist IMB_flipx, IMB_flipy, rotation by (multiple of) 90 degrees could be a function next to them. Which is fairly similar to what soemeone else is doing over at #115661 (in order to auto-rotate videos based on their orientation metadata).

I think `IMB_transform` could be used for this, even if it's somewhat overkill. You would get multi-threading "for free" though. If not that, I think factoring out the actual rotation function into separate piece of code would be good. Like there already exist `IMB_flipx`, `IMB_flipy`, rotation by (multiple of) 90 degrees could be a function next to them. Which is fairly similar to what soemeone else is doing over at #115661 (in order to auto-rotate videos based on their orientation metadata).
Harley Acheson added 1 commit 2024-01-20 19:15:42 +01:00
Author
Member

@aras_p - I think IMB_transform could be used for this, even if it's somewhat overkill. You would get multi-threading "for free" though.

Ohhhh. That sounds like a perfect routine to help make an "Arbitrary Rotation" for any angle and selectable center? Any hints for what such a transform matrix would look like - for someone clueless about such things? Or how I would find out ahead of time how big of a rectangle would comprise the result without cutting anything off? I'm assuming I'd have to know this in order to allocate the target bitmap correctly.

If not that, I think factoring out the actual rotation function into separate piece of code would be good. Like there already exist IMB_flipx, IMB_flipy, rotation by (multiple of) 90 degrees could be a function next to them.

I just cleaned up my mess of code so the different rotations only vary by a single line.

I did wonder where it should go and only stuck it all in image_ops because of the similar code for IMAGE_OT_flip. But yes, now wondering why that code doesn't use IMB_flipx and IMB_flipy.

Aras, if this code is moved to rotate.cc, what would you suggest for rotational arguments? Three enums? Integers of degrees but only working on 90, 180, etc?

> @aras_p - I think `IMB_transform` could be used for this, even if it's somewhat overkill. You would get multi-threading "for free" though. Ohhhh. That sounds like a perfect routine to help make an "Arbitrary Rotation" for any angle and selectable center? Any hints for what such a transform matrix would look like - for someone clueless about such things? Or how I would find out ahead of time how big of a rectangle would comprise the result without cutting anything off? I'm assuming I'd have to know this in order to allocate the target bitmap correctly. > If not that, I think factoring out the actual rotation function into separate piece of code would be good. Like there already exist `IMB_flipx`, `IMB_flipy`, rotation by (multiple of) 90 degrees could be a function next to them. I just cleaned up my mess of code so the different rotations only vary by a single line. I did wonder where it should go and only stuck it all in `image_ops` because of the similar code for IMAGE_OT_flip. But yes, now wondering why that code doesn't use `IMB_flipx` and `IMB_flipy`. Aras, if this code is moved to `rotate.cc`, what would you suggest for rotational arguments? Three enums? Integers of degrees but only working on 90, 180, etc?
Harley Acheson added 1 commit 2024-01-20 20:21:39 +01:00
Harley Acheson added 1 commit 2024-01-20 20:25:03 +01:00
Harley Acheson added 1 commit 2024-01-20 21:39:32 +01:00
Harley Acheson changed title from WIP: UI: Image Rotate to UI: Image Rotate 2024-01-20 21:41:57 +01:00
Harley Acheson requested review from Campbell Barton 2024-01-20 21:42:30 +01:00

That sounds like a perfect routine to help make an "Arbitrary Rotation" for any angle and selectable center?

I would not implement that arbitrary angle functionality now. It may be tempting to add a bunch image editing operations because they are relatively straightforward. But there are a of design and implementation questions if someone wanted to turn the image editor into more a a complete editor, and I rather see us focus our efforts on other things than go into that rabbit hole.

> That sounds like a perfect routine to help make an "Arbitrary Rotation" for any angle and selectable center? I would not implement that arbitrary angle functionality now. It may be tempting to add a bunch image editing operations because they are relatively straightforward. But there are a of design and implementation questions if someone wanted to turn the image editor into more a a complete editor, and I rather see us focus our efforts on other things than go into that rabbit hole.
Author
Member

@brecht - I would not implement that arbitrary angle functionality now...

No worries.

I also really don't mind dropping this orthogonal rotation PR; was just a shiny thing to keep me occupied on the weekend for a bit. This 90 degree rotation seems a bit more foundational though since this needs to happen often when taking images off camera. And it sounds like VSE might want similar.

> @brecht - I would not implement that arbitrary angle functionality now... No worries. I also really don't mind dropping **this** orthogonal rotation PR; was just a shiny thing to keep me occupied on the weekend for a bit. This 90 degree rotation seems a bit more foundational though since this needs to happen often when taking images off camera. And it sounds like VSE might want similar.

Rotating by 90° doesn't really raise any design question, so I have no objection to that.

Rotating by 90° doesn't really raise any design question, so I have no objection to that.
Harley Acheson added 2 commits 2024-01-30 19:36:32 +01:00
Harley Acheson requested review from Brecht Van Lommel 2024-01-30 19:39:54 +01:00
Brecht Van Lommel requested changes 2024-01-30 20:05:17 +01:00
@ -2844,0 +2901,4 @@
ot->poll = image_from_context_has_data_poll_active_tile;
/* properties */
PropertyRNA *prop;

This should be an enum as it doesn't actually support more values.

This should be an enum as it doesn't actually support more values.
Harley marked this conversation as resolved
@ -16,1 +16,4 @@
bool IMB_rotate_orthogonal(ImBuf *ibuf, int degrees)
{
if (ibuf == nullptr) {

This should not be needed.

This should not be needed.
Harley marked this conversation as resolved
@ -17,0 +21,4 @@
}
/* Fold to -359 to 359. Note Mod operator is machine-dependent for negative operands. */
degrees = degrees - (degrees / 360) * 360;

This shouldn't be needed if only fixed degrees are supported.

This shouldn't be needed if only fixed degrees are supported.
Harley marked this conversation as resolved
@ -17,0 +42,4 @@
for (int y = 0; y < size_y; y++) {
for (int x = 0; x < size_x; x++) {
const float *source_pixel = &orig_float_pixels[(y * size_x + x) * 4];
if (degrees == 90) {

Move this check out of the loop and duplicate the for loops. More efficient that way.

Move this check out of the loop and duplicate the for loops. More efficient that way.
Harley marked this conversation as resolved
@ -17,0 +45,4 @@
if (degrees == 90) {
memcpy(&float_pixels[(y + ((size_x - x - 1) * size_y)) * 4],
source_pixel,
sizeof(float[4]));

Float images can have arbitrary number of channels, so this should use const int channels = ibuf->channels;.

Float images can have arbitrary number of channels, so this should use `const int channels = ibuf->channels;`.
Harley marked this conversation as resolved
Harley Acheson added 2 commits 2024-01-31 04:24:09 +01:00
Brecht Van Lommel approved these changes 2024-01-31 20:43:27 +01:00
Harley Acheson added 1 commit 2024-01-31 23:03:50 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
edcc57a58c
Merge branch 'main' of projects.blender.org:blender/blender into ImageRotate
Author
Member

@blender-bot build

@blender-bot build
Harley Acheson merged commit 93562a1cc5 into main 2024-01-31 23:36:37 +01:00
Harley Acheson referenced this issue from a commit 2024-01-31 23:36:37 +01:00
Harley Acheson deleted branch ImageRotate 2024-01-31 23:36:39 +01:00
YimingWu referenced this issue from a commit 2024-02-05 10:56:05 +01:00
Jonas Dichelle referenced this issue from a commit 2024-02-08 17:29:07 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
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: blender/blender#117352
No description provided.