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



Comments

  • Found bug in CDib::Paste

    Posted by Legacy on 06/09/1999 12:00am

    Originally posted by: Timothy Buck

    I like this class!
    
    

    I found a bug in CDib::Paste( CDib *Dib ), the line,

    Create ( Dib->m_Size.cx, Dib->m_Size.cx );

    should read,

    Create ( Dib->m_Size.cx, Dib->m_Size.cy );

    Reply
  • Missing res directory

    Posted by Legacy on 12/23/1998 12:00am

    Originally posted by: Bill oatman

    Your rotozoom example zip file is missing the res directory and its contents.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Best-in-Class organizations execute on a strategy that supports the multi-channel nature of customer requests. These leading organizations do not just open up their service infrastructures to accommodate new channels, but also empower their teams to deliver an effective and consistent experience regardless of the channel selected by the customer. This document will highlight the key business capabilities that support a Best-in-Class customer engagement strategy.

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds