EBGfx library to get fast access to image data

The EBGFX Library is a Free MFC compatible library created to get fast
access to image data and include several functions not available in the
windows gdi.

Whether you create a Ray-Tracer, an Image Processing
Library, a Painting Program or Games, you need direct pixel access,
you can’t just use GetPixel, SetPixelV. One way to achieve this is using
Dibs (Device Independant Bitmaps). To get rid of the details of creating
destroying DibSections I wrote a CDib class.
However I want more
than just Creating and Destroying Images, I want to have several layers
and techniques to composite those layers into a final Image, so I’ve
implemented some of the Compositing techniques found in Photoshop.
(As a GFX Artist I’m more acquainted with those techniques as with
src & dst Blend functions).

I also included some routines to Copy/Paste
parts of Images to other Images, with optional Compositing.
The current public version of the Library contains two classes :
CDib, which can be used as an offscreen surface, a tile, a layer, and
which includes several Compositing techniques and Drawing Primitives.
CDrawDib, which can be used to write a CDib directly into Video
Memory with optional Stretching and/or Dithering the Dib.

Two other classes are not yet released : CFilter, which implements a lot of
Image Processing Filters, and CFileHandler which loads several Image
Formats like BMP, JPG, GIF, TGA, TIFF, PCX, PSD, etc.
In the future I’ll probably create a DirectDaw based version for
Games.

Compositing


Original

Original Blend Darken Difference Lighten Multiply Screen

What does each function do ?

Blend : Blends the src color with the dst color (alpha from 0
to 255)
Darken : dst = Darkest Color ( src, dst )
Difference : dst = Abs ( src-dst )
Lighten : dst = Lightest Color ( src, dst )
Multiply : dst = src*dst
Screen : dst = (255-src)*(255-dst)

What can they be used for ?

Blend : That nice Glassy effect for windows, water, fading
Darken : Shadows
Difference : Inverting
Multiply : Exclude certain color channels, masking
Lighten, Screen : Flares, Fire, Explosions

This is a small example which shows some of the functionality
of the CDib and CDrawDib classes : RotoZoom.zip

It’s a small RotoZoomer with optional Motion Blur (using the CDib functions)

This is a second example testing the new CopyDC/PasteDC functions,
It grabs the opposite part of the screen, and puts it behind Glass.
There is still a little problem though (see Second Screenshot), how can you grab the screen
before your window gets painted ? If anyone knows how to fix this,
please mail me

Bugs & Warnings

Send Suggestions, Speed Increases and Bug Reports to ef00@luc.ac.be

Bugs :
  • No known Bugs at this Time
Warnings :
  • Line drawing has no clipping at the moment, so
    keep
    the points within the clipping region please.
  • The Rect functions have clipping capacity, if you
    don’t
    need clipping you can throw the clipping code
    away for
    extra speed.
  • Copy means copy from ‘this’ to first param.
  • Paste means copy from first param to ‘this’.
  • Only 32-bit Dibs are supported at this time.
  • The Dibs are upside-down because DrawDibDraw
    won’t accept them otherwise.
  • You won’t find a SetPixel function because it’s
    just
    stupid to create such a function, use
    m_Bits[y*m_Size.cx+x]=Color instead.
    Or define a macro :
    #define SetPixel(x,y,C) m_Bits[y*m_Size.cx+x]=C

Future Enhancements

  • Speed
  • More primitives.
  • Maybe Render-States which determine what function
    to
    use.



Download demo project and source code: RotoZoom – 160KB

Download demo project XRay.zip – 145KB

Date Posted: 5/08/98

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read