Important alert: (current site time 7/16/2013 2:27:35 AM EDT)
 

winzip icon

Real-time Image Curves (using cubic splines) - just like Photoshop

Email
Submitted on: 6/3/2007 9:46:12 AM
By: Tanner H  
Level: Intermediate
User Rating: By 17 Users
Compatibility: VB 5.0, VB 6.0
Views: 20678
author picture
(About the author)
 
     By request, here's another first of its kind in VB: a fast, accurate, real-time image curves dialog. (This should be familiar to the PhotoShop users among us :) Curves is similar in theory to my previous "Image Levels" post and standard gamma correction, but it provides a much more powerful interface for adjusting the luminance of an image. This project provides results very similar to Photoshop's, and it allows the creation of more spline knots (32 instead of 16). The cubic spline code on which I based my code was taken from Jason Bullen's excellent "Simple Cubic Spline Curve Plot" (http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=11488&lngWId=1). The code is well-commented and very fast - please post comments, requests for future Photoshop-related code, and many heaps of praise (as this was a complicated routine to sort out...)! Update 2/May/07 - disable loading of icons and warn the user against loading very large images.

 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Real-time Image Curves (using cubic splines) - just like Photoshop
'**************************************
DIB sections
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 5 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
5/12/2007 10:51:12 PMHerman CK

Just as when PSC has been as dull as it can be since long, Tanner now
injects some freshness. If only 5% of the postings in PSC could be as
worthy as this one, PSC would have some shine again. Everything functions
out as the coder claims, and the code is clean and organized, and more
importantly not of the usual stuff being repeated again and again. Since the coder invites, would it be interesting to see the "liquify" filter of PhotoShop?


(If this comment was disrespectful, please report it.)

 
5/13/2007 12:41:11 AMRobert Rayment

Excellent DIB class and gamma effect demo. Would be a nice addition to any paint program. Thanks for sharing.
(If this comment was disrespectful, please report it.)

 
5/13/2007 10:17:54 AMHerman CK

Tanner: Just a few minor points for your reference in next update, perhaps (i) add a few lines to trap 32-BPP icon or a PNG item in Vista icon file to avoid runtime; (ii) add a few lines to trap runtime on non-XP when pic size well over 3 mb (since pic AutoRedraw is True) and (iii) recheck a calculation for a function in the image byte array handling class. I can send you the above mentioned if interested.

(If this comment was disrespectful, please report it.)

 
5/13/2007 10:48:19 AMSpector

I tried writing a image curves function a while back but never good getting it working quite right. Thanks a lot for pointing out what I was doing wrong. There isn't near enough well written, advanced image processing code for visual basic and this is a excellent addition. Look forward to seeing your next Photoshop related demo.
(If this comment was disrespectful, please report it.)

 
5/14/2007 1:05:24 PMTanner H

Herman - thanks for the "minor points." They are appreciated! In the next update, I will do some basic file checking to prevent those run-time errors. I would also be interested in the image byte array function calculation error you mentioned. Please send it my way! Thanks to everyone else who has commented. Next update will probably include the ability to delete knots in the spline. Keep the suggestions comin'.
(If this comment was disrespectful, please report it.)

 
5/14/2007 2:16:56 PMBill K of Boston

5 by 5 NICE Work!!!!!
(If this comment was disrespectful, please report it.)

 
5/15/2007 6:37:32 PMAhmedQatar

5 by 5 !!
(If this comment was disrespectful, please report it.)

 
5/22/2007 8:25:17 AMT.Jackson

Excellent! - curves is very powerful indeed, I use it all the time in Photoshop. *****
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.