|
-
Apr 20th, 2025, 01:03 PM
#1
cCropper: Simple, "Smart" RC6/Cairo Image Cropping Class
cCropper is a small and fast VB6/RC6 class designed to make image cropping easy, and to allow you to add image cropping to your VB applications (nearly) effortlessly.
In addition to being a useful stand-alone class, the code has also been thoroughly commented, making it useful as learning material for RC6/Cairo graphics features and functionality.
Features:
- UI Mode:
Let users visually select, move, and resize crop areas with the mouse.
- Programmatic Mode:
Define crop rectangles and process images entirely through code.
- Format Support:
Load and save PNG, JPEG, and BMP files.
- "Smart" File Size Control:
Automatically resize files to stay near a target maximum byte size - perfect for uploads and email attachments.
- Image Size Control
Define the maximum pixel width/height for your cropped image - useful for generating thumbnails.
Screenshot:

Notes
Requires the RC6 library.
Source Code:
RC6CairoImageCropper4.zip
(Includes demo image which accounts for most of the file size - source code is < 50kb)
Enjoy!
Last edited by jpbro; Apr 24th, 2025 at 03:57 PM.
-
Apr 20th, 2025, 01:14 PM
#2
Re: cCropper: Simple, Smart RC6/Cairo Image Cropping Class
Quick note about the "Smart" File Size Control feature - it's fairly experimental, so please let me know if you get any surprising results (ideally providing an image and export format for testing). Thanks
-
Apr 23rd, 2025, 11:42 AM
#3
Re: cCropper: Simple, "Smart" RC6/Cairo Image Cropping Class
Added the ability to set a maximum Pixel size for the image. Useful for generating thumbnails (image will be centred horizontally and vertically if it doesn't fit the max pixel width/height squarely).
-
Apr 24th, 2025, 03:59 PM
#4
Re: cCropper: Simple, "Smart" RC6/Cairo Image Cropping Class
Added a "SharpenOnShrink" Boolean parameter to the SaveImage method. When shrinking images, they can look a bit blurry, and Sharpening them can produce more pleasing/pseudo-detailed results:

My approach will do a single-pass Sharpen if the scaled image size is <67% of the original image size, and double-pass Sharpen if < 33%.
-
Apr 27th, 2025, 08:57 PM
#5
Hyperactive Member
Re: cCropper: Simple, "Smart" RC6/Cairo Image Cropping Class
Thank you, this is wonderful . For my purposes I will likely rewrite using GDI+. Nothing against RC6 but don't want the extra dependencies because my use case is inside a custom control. And I think that Cairo uses GDI & GDI+ as backends on Windows anyway.....
-
Apr 28th, 2025, 03:45 AM
#6
Re: cCropper: Simple, "Smart" RC6/Cairo Image Cropping Class
Very useful tool, I'm happy with an RC6 version or plain GDI+.
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
-
Apr 28th, 2025, 03:46 AM
#7
Re: cCropper: Simple, "Smart" RC6/Cairo Image Cropping Class
> And I think that Cairo uses GDI & GDI+ as backends on Windows anyway.....
No, it does not. This would be very backwords logic and ChatGPT confirms: https://chatgpt.com/share/680f402b-9...9-2f83699721b3
cheers,
</wqw>
-
Apr 28th, 2025, 08:46 AM
#8
Re: cCropper: Simple, "Smart" RC6/Cairo Image Cropping Class
 Originally Posted by SomeYguy
Thank you, this is wonderful  . For my purposes I will likely rewrite using GDI+.
Glad you like it, and looking forward to your GDI+ version if you should decide to share it. Be interesting to compare LoC and # hours it takes to implement in GDI+ vs. RC6/Cairo.
-
Apr 28th, 2025, 08:47 AM
#9
Re: cCropper: Simple, "Smart" RC6/Cairo Image Cropping Class
No, RichClient 6 Cairo wrapper does not use GDI+.
Here’s a breakdown:
RichClient 6 (RC6) is a COM-based framework developed by Olaf Schmidt for VB6 and other COM-capable environments.
The Cairo wrapper in RC6 is a direct binding to the Cairo graphics library (a C library).
Cairo is a powerful, hardware-accelerated 2D graphics library that renders directly using backends like Win32, Direct2D, OpenGL, Skia, and others — but it does not rely on GDI+.
RC6 accesses Cairo.dll (and some helper DLLs) directly through lightweight COM classes.
In fact, Olaf deliberately avoided GDI+ because GDI+ is slower, more limited, and less accurate (especially with alpha-blending and transforms) compared to Cairo.
Straight from ChatGPT
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
-
Apr 28th, 2025, 12:13 PM
#10
Hyperactive Member
Re: cCropper: Simple, "Smart" RC6/Cairo Image Cropping Class
wqweto: Meant to quote your reply but forgot to reply w/quote. Anyway - Looks like the AIs don't agree with each other on this but I tend to believe ChatGPT so I'm sure you're right. I agree with you that it would be backward logic for Cairo but GDI/GDI+ are still great options in many cases and the .NET framework simply wraps GDI+ for its 2D graphics capability.
Regarding RC6, it truly is wonderful and a fantastic achievement and tool by Olaf and I do use it for some things. But for certain applications I just can't redistribute several base dlls and/or use manifests for reg-free running.
Last edited by SomeYguy; Apr 28th, 2025 at 12:19 PM.
-
Apr 28th, 2025, 12:23 PM
#11
Hyperactive Member
Re: cCropper: Simple, "Smart" RC6/Cairo Image Cropping Class
 Originally Posted by jpbro
Glad you like it, and looking forward to your GDI+ version if you should decide to share it. Be interesting to compare LoC and # hours it takes to implement in GDI+ vs. RC6/Cairo.
Most certainly I will be happy to share whenever I get it finished .
-
Apr 28th, 2025, 03:30 PM
#12
Re: cCropper: Simple, "Smart" RC6/Cairo Image Cropping Class
You cannot trust AI to give you an accurate answer, it is just as likely to give you hearsay. I was recently investigating a method of reading an icon from a HIcon via a bitstream and it invented two very plausible APIs that would have done the trick perfectly, if only they had ever existed.
https://github.com/yereverluvinunclebert
Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.
By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.
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
|