Please support our sponsor:
Welcome To DirectX 4 VB! Multimedia Visual Basic at its best...




DirectDraw: Memory Array Effects
By: Jack Hoxley
Written: June 2000

Download: Sample program and DLL (47kb) or just DLL (18kb)


As mentioned in the memory access tutorial, you can apply several effects to the surface using your own algorithms. This sample/tutorial will show you how to make you're own and use the ones provided.

I have written a VB DLL that does all the number crunching; there are two main reasons for this -
1. Speed, there is a significant speed advantage if a compiled DLL does the number crunching compared with your EXE doing the number crunching. The DLL can be optimized using VB's compiler to be faster at array access, which is basically what the effects are all about.
2. Size. The final selection of code that are the effects ran into over a thousand lines of code; it made it much simpler to read/write the host program when we only had to call the function once. This isn't an obvious point, but remember, if the master EXE has 10,000 lines of code it will be slow, but if the DLL has 9000 lines and the EXE has 1000 it will be faster.
3. Reusability. Now I've written this DLL I can improve it, add to it and enhance it and it will have an immediate effect on every program written to use it. Also, because it isn't built into a project I can use time-and-time again, just from one procedure call.

I suggest the you download the sample program to see how it works.

Theory
The theory behind all the effects is applying formulas to the entries in the array. The DLL is passed an array of bytes (representing the picture) and it runs through every value and modifies it. Each entry represents ONE colour channel of a pixel, which is why some recursive formulas make the screen go greyscale. Look at the source code for the DLL and you'll see that there is a simple formula run through it. Most of the effects in this library were not based on solid knowledge; instead they were based on guesswork and named according to what the output was like.

Read the Info.Txt for more information on the effects included; and about adding you're own effects to the collection.

DirectX 4 VB © 2000 Jack Hoxley. All rights reserved.
Reproduction of this site and it's contents, in whole or in part, is prohibited,
except where explicitly stated otherwise.
Design by Mateo
Contact Webmaster
This site is hosted by Exhedra Solutions, Inc., the parent company of RentACoder.com and PlanetSourceCode.com