A Visual Basic PaintBrush / Imaging Program
Author: Stefaan Casier
Author's WebSite: http://home.planetinternet.be/~scasier
This excellent example from Stefaan Casier shows the basics of creating a professional paint program and how to implement many of the features that users expect for granted. Be sure to study this code well and learn from it.
Standard Screen :
Zoomed Image :
Paint256 v1.05
10/07/99 - translated 18/03/2000
DESCRIPTIONThe program has to be run in a 256 colors-screen modus state, since it concentrates on making bitmaps with a 256 colors pallet, containing gradient or fluent colors. Besides using fluent colors, the program also has a feature adding shade to all drawings. The fact, to apply fluent colors and shade is made so easy, makes this program special. It is at least a good addition to other painting programs.
Most functions work in such an obvious way, they need no explanation. So I provide you here with those things that are not so obvious.
SIZE Absolute maximum = 1024 x 1024 pixels. Each scale- or zoom factor has it's own maximum (XY): x1 1024 This a mathematic maximum that would produce an Overflow if passed Tips: THE COLOR PALLET You change or set it, There are some different ways to set a new pallet: One of the powers of Paint256 is working with fluent colors. When they are unavailable, a number of functions become useless.
THE UPPER TOOLBAR Many functions react differently depending on whether selection-modus is on or not. If the selection-modus is on, most functions will act on the current delimited selection, otherwise it will be on the whole image. This is the case with: Save, Copy, Pallet-Rotation, Move, Mirror, Delete, Replace (click the mouse with the mouse - nice no?) ... Open en Paste have something similar. Moving over a button with the mouse causes a tip to popup, with the button's name or description. KEYS (in main-window) C Copy You can move, copy/paste a selection with the mouse combined with the shift- or control-keys. Without any key, you only move the rubber box. Clicking in the image combined with the Alt-key, will change the current (left/right) mouse color into the color under the mouse pointer. You select the background-color in the pallet, holding the Alt-key down. PICTURES This is a browser looking for bitmaps on disk. You can check the saved results. Delete doubles... You can copy bitmaps to the clipboard to paste them later... If you want to mix different bmp's you will have to check their pallet for compatibility. In most cases the pallets have to be identical. - Always load & select the pallet of a bmp-file, before you paste the bmp itself. FUNCTIONS * = click them with the right mouse button to set their parameters by means of a dialog. In most cases you can repeat the last action with new left/right color settings. You can Undo before, or not. This way you can try things out until you find the best setting. STYLE ----> do experiment, you will see, it's easy TEXT A multi-line text you can align (left/right/center). A single line of text you can tilt or turn over. To place it in your image you can think of it as a stamp. Click in the image, without releasing the mouse button. A 'rubber box' you can move around, will appear showing the size of the stamp. The stamp is made the moment you release the mouse button. FLUENT COLORS A condition to use this is of course there has to be a pallet with gradient fluent colors. Pallets extracted from a bitmap, will probably not have such a pallet... Select in the pallet on the left, the Start color with the left mouse button and the End color with the right mouse button. Then you choose in the Fill-modus dialog, the preferred color pattern. Each following drawing action will use these selected settings and produce fluent colors.
x2 1024
x4 546
x6 364
x8 273
- get to know the program using a small size like 100*100
- without using the grid, everything works faster
E Exit
O Open
P Paste
B Save
A Size+Zoomfactor
U Undo
W Clear
S Shades dialog
V Fill modes dialog
space Repeat previous action (<> filling)
shift+ M Pattern-Mask (to use with small sizes - testing)
K Show real size image
Cursor Keys:
(doesn't work on black surfaces !)
Download Zipped Source Code (97k)
Download Zipped EXE and Help File (127k)
This article was originally published on April 11, 2000