# Dib Sections & Bitmaps

In Windows, there are 2 basic kinds of bitmaps:
DDB - Device Dependent Bitmaps which are a legacy from the early days of the OS.
DIB - Device Independent Bitmaps.
The basic difference is that the former are stored in a formatto match the display adapter settings and so have a problem porting the colour system whereas the latter do not and therefore are the preferred choice for graphics. However, the stored format of DDBs means that they can have better performance than DIBs. Windows is forced to accomodate both for the sake of backwards compatibility.
ARWEN uses a DIB section library. DIB sections are DIBs stored in memory that the user can directly write to. The library has a basic set of routines for manipulating DIBs including pixel and line drawing routines. Please see the DibSection documentation and the source code for details.
DIBs can be created from scratch or can be loaded from a bitmap on disk or pasted from the clipboard. They can also be saved to disk as bitmaps or copied to the clipboard. The library supports only 8-bit or 32-bit DIBs. Whenever a bitmap of a different colour depth is encountered, the library will convert it into one of the supported formats. 8-bit DIBs have an associated 256 entry palette which is easy & fast to manipulate to provide effects such as fading, contrast & brightness adjustment etc.. These DIBs also have better blitting performance than 32-bit DIBs, however, those have unlimited access to all possible colours so they are useful for high-resolution graphics but they do require about 4 times as much memory and are slower to manipulate. An important advantage of DIB sections is that the user is not forced to use the cumbersome Windows GDI system - those fast action games you may have seen for Windows probably use DirectX or OpenGL but NOT the normal GDI functions. Since the DIB pixels are directly accesible we can use routines like mem_set() to do things like clear the whole image or draw horizontal lines at near maximum speeds. The library also has a fast line-drawing routine that takes advantage of having direct access to the DIB. Drawing text on DIBs is also possible but the font used is a default (stock) one as Font creation in Arwen has not been added yet. Lastly, all graphics routines in the library are written entirely in Euphoria. This means that direct operations, such as line drawing, will benefit greatly from translation & compilation as there is no overhead for calling a DLL routine to perform the operation. Such applications can be highly graphic performant.