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

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

  • On-demand Event Event Date: December 18, 2014 The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this webcast and join industry experts as …

Most Popular Programming Stories

More for Developers

RSS Feeds