Super Affine Tool Thing
Quite a bit of progress on ImageZ over the last few nights. Didn't get a lot done in the yard over the weekend - a visitor on Saturday and I was lazy today but I got a couple of hours of gardening in - mowed the lawns, transplanted some rhyzomes from the patch of grass i have to the patch of non-grass I don't want, weeded one of the vegetable patches and shifted most of my pots out of the way ready for more work readying the yard.
Fixed up a few issues with using non-pre-multiplied alpha, but only for normal blending mode - I know all the other blending modes are still doing it wrong.
Actually I can't really remember where I was at last time and how much i've done since then, it's all blurring into one long indistinct memory.
But I did work on what i've been calling a 'super affine tool'. It combines the various affine operations into a single tool in a way that should still be accessible.
A scaled, rotated and translated cat
I've been thinking about this for quite a while but finally sat down to nut it out. When you bring up the tool the following controls pop up in the middle of the image:
- Centre Disc
- This is the location of the image relative to the centre of the image. i.e. a simple translate.
- Inner Ring
- Sets the location of the rotation centre point on the source image.
- The two Parallelograms
- Adjust the shear in X or Y. The shapes move as you drag them in proportion to the shear amount.
- The two Rectangles
- Adjust the scaling in X or Y. The shapes scale as you drag the mouse in proportion to the scaling amount.
- Outer Ring
- Adjusts the rotation angle. Yes it probably needs some sort of indicator, although the moving image gives you that.
I'm still tweaking the affine transform matrix it produces to make it behave nicely. It applies the rotation, then the shear, scale and finally offset. This makes it behave mostly how you'd expect it to, although in some cases you'd have to run it multiple times to get exactly what you wanted. And it doesn't work properly if the view is zoomed ... and you can't actually commit the operation yet.
Damnation in hell Java is fast at this though - it must be accelerating it using the graphics card. I'm even using linear interpolation with alpha blending for the real-time preview and it's really nice and quick - at least when using one of the native layer types. Even a full-resolution image from my digital camera at 4288x2848 is flinging around at ~15-20fps.
I'm not entirely happy with the tool options on the left - there's a lot of numbers and spin buttons - but I guess it's not completely out of the question.
Actually I was also looking at putting tool options there which is why it's shown up there in the first place. But i'm not sure about that yet - if I do that then most tool options will really need to be per-image otherwise the behaviour will be a little odd. I'm not sure if this is desirable. For example if you set the tool to 'pen' you might reasonably expect it to be 'pen' on another window. Or maybe you might not - it probably doesn't matter either way.
I also had a good long dig at fixing some issues with the Amiga style menus. Basically some bugs(?) in the lightweight comboboxes were giving me nightmares. I was using an event listener on the glass pane to capture mouse button events. But the problem is when you do that you end up having to re-route the mouse events manually! I did manage to get that working quite well over the last few weeks except for the combo boxes. If you hold down the button and drag when selecting a combobox item it works fine, but if you click twice it doesn't! I eventually found similar discussions in the java forums and adopted a new version which just attaches a low-level event listener instead and simply snarfs the menu-button event. It reduces some of the flexibility I might have had in say allowing context menus as well, although I can probably hack that if required. But now the menu works reliably and doesn't interfere with the rest of the application. It's probably something that would be turned off if you wanted to use a Macintosh since that separates menus from windows already, but that is of no concern to me.