-
Sep 20th, 2021, 09:33 AM
#1
Simple Image Manipulation App (Flip, Rotate, Crop)
This is a simple image manipulation app with the following features:
- Load an image (Press L)
- Horizontal flipping (Press H)
- Vertical flipping (Press V)
- Rotation by pressing R (90 degree clockwise rotation) or SHIFT+R (90 degree counter-clockwise rotation)
- Cropping (click & drag mouse to define a crop rectangle)
- File navigation (press SPACE to load the next image in the active folder, press BACKSPACE to load the previous image in the folder).
- Save modified image (Press S)
Examples:
I wanted to learn more about Cairo graphics in RC6 by putting together a fully functional (albeit small) application. I haven't used RC6 Widgets for this project though, just vanilla VB6 forms & controls.
KNOWN BUGS:
Saving a cropped & rotated image will likely crop at the wrong location. Still trying to figure out why, and wouldn't mind some help with this part It might be nice if CCairoSurface had a Crop(X1, Y1, X2, Y2) method that would return a new CCairoSurface cropped out of the full-sized surface.
OTHER NOTES:
I'm not convinced I've gone about the Cairo stuff optimally - if Olaf or any other Cairo-knowledgable folks would be kind enough to review the code and make suggestions, it would be much appreciated.
Source Code (Requires RC6):
RC6CairoImageEditor.zip
Hope you enjoy the demo, and maybe even learn something from it.
-
Sep 20th, 2021, 11:04 PM
#2
Re: Simple Image Manipulation App (Flip, Rotate, Crop)
Originally Posted by jpbro
It might be nice if CCairoSurface had a Crop(X1, Y1, X2, Y2) method that would return a new CCairoSurface cropped out of the full-sized surface.
I've so far not included this (because such a function would only save one line of code) -
but did so now for the sake of more convenience (it will be available in the next release).
Here's the "non-integrated" variant of that new method:
Code:
Public Function CropSurface(SrcSrf As cCairoSurface, x, y, dx, dy) As cCairoSurface
Set CropSurface = Cairo.CreateSurface(dx, dy)
CropSurface.CreateContext.RenderSurfaceContent SrcSrf, -x, -y
End Function
Olaf
-
Sep 21st, 2021, 08:33 AM
#3
Re: Simple Image Manipulation App (Flip, Rotate, Crop)
Hi Olaf,
Thanks for the CropSurface function, and you're right that it's not a big savings in code, but it's a bit of convenience and nice to have.
I realize though, that I've made a mistake with my request. What I really think would be useful is a Crop method on a cCairoContext. For example, in my little demo app, the user might draw a crop rectangle, then rotate and flip the image. This is handled perfectly on screen - the crop rectangle, flips, scales, rotates, etc... synced to the transformations to the full size image. I want to then save the flipped and rotate image that is cropped at the right position. If I could pass the screen units to a crop method on the context, I don't have to figure out rotations/flips/etc... for positioning the crop rectangle myself since the context will transform the passed values automatically.
That said, maybe there's an easy way to do this that I a missing that wouldn't require such a method? I'll keep experimenting.
-
Jan 3rd, 2022, 06:47 PM
#4
Lively Member
Re: Simple Image Manipulation App (Flip, Rotate, Crop)
Thanks jpbro
Was wondering if you could possibly include a load picture function with a scrolled picture for "larger pictures"? I made a few fractal programs and was curious how it could be done with Cairo.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|