Graphics Effects

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math Topics]   [Library]   [Utilities]

Search

 

Search DelphiForFun.org only

Support DFF

 

If you shop at Amazon anyway,  consider using this link. We receive a few cents from each purchase.   Thanks.

In Association with Amazon.com

 

Support DFF

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

 

 

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

 

Search DelphiForFun.org only

 

 

 

 

Introduction

Here is a program written by Ivan Sivak (aka Ivanoslav), a bright, young 16 year-old Delphi programmer from Czechoslovakia.  

It contains 15 graphics effects demonstrations.  I don't know that any of them are original, but it is a fairly complete set of effects that can be obtained; mostly, except for the first two text demos,  by pixel manipulation.

I added some user edit fields for values that Ivan had hard coded and made a few other changes, but 90+% of the code is as he sent it.   

Here are the effects:   

bulletRaised text.  A clever way to give text a raised appearance by drawing darker text offset lower and lighter text higher on the screen. 
bulletRotated text.  Using the logical font escapement field to control the angle at which text is drawn. 
bulletImage selection.  Copy a rectangle from one image to another. 
bulletPixel color filtering.  Remove Red, Green or Blue pixels from an image (leaving the other two colors to form Cyan, Magenta, or Yellow).
bulletConversion to grayscale.  Replaces colors in each pixel  with a weighted average of the three.  The default weighting ( 0.2989 for red,  0.5866 for green, and 0.1145 for blue) is  the NTSC standard  that reflects the apparent brightness sensitivity of the human eye; least sensitive for green and most sensitive for blue.  
bulletConversion to black and white.   If the weighted average of the three colors in a pixel  is higher than a threshold value, make  the pixel white, otherwise make it black.  
bulletPixel distribution.  I have no idea what this is, but the it makes an interesting picture. 
bulletColor inversion.  Make the "negative" of a color image by subtracting each color value from 255 for each pixel.
bulletChange contrast and brightness.  Here is where I made my most significant contribution to the project.  Ivan originally had  only two levels of contrast adjustment in his code.  I generalized that to multiple levels.  In the process I noticed that images tends to get darker as contrast in increased and decided that we also needed a brightness adjustment.  That led to a side trip into the world of HSV (hue, saturation, value) color representation.  This is also sometimes referred to as the HSB;   (hue, saturation, brightness) , system.   Adjusting brightness requires converting the RGB pixel value to the HSV system, adjusting the "V" (brightness) and converting back to RGB..  
bulletMaking a relief image.  Convert each pixel to a gray scale constant plus the difference between the grayscale value of this pixel and the pixel three pixels up and to the left.  
bulletPixel sorting.   Another one I did not look at much.  If anyone has any comments on it, I'll be happy to add them here. 
bulletBlob deformation.  Replace the image with lots of randomly placed ellipses colored by averaging the colors of some pixels within the ellipse.
bulletBlending 2 pictures together.  Simply replace each pixel with the weighted average of the two corresponding pixels in the original images.  The weighting may be constant or varied.  The variation samples here are based on the X coordinate to cause a fade-in or fade-out effect. 
bulletSine wave deformation. Relocate each pixel based sine or cosine function applied to the coordinates.
bulletBubble spot magnify deformation.  This is one of the screensaver effects in the MSPlus software package.   Here we just magnify an area around a clicked point.   I haven't analyzed how or why it works.  It seems to relocate pixels a distance inversely proportional to their distance from the clicked point. 

All-in-all, an impressive piece of work that I thought worth passing along,   Thanks Ivan, and good luck with your future endeavors.  If you decide to become a professional programmer, success seems very likely!

The source and executable code below each contain the two bmp images used.  Together they add about 400k to download sizes (400k for source and 600k for executable.)    The "original_picture.bmp" image is of my kids about 35 years ago.  Son Steve's kids especially,  will be so proud to see their Dad immortalized this way! 

Browse/Download Source 

bulletBrowse source code
bulletDownload source 
bulletDownload executable

Further Explorations

We have not worried much about speed in the code.  Delphi Help says that   TScanLine is considerably faster than pixel by pixel manipulation.   And there are areas where I'm sure existing code could be made more efficient.      
No real animation or  sprite effects here yet.

 

Created: August 25, 2003

Modified: May 18, 2009

 

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2011, Gary Darby    All rights reserved.