Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - <b>readdib()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
ReadDIB()
Read a device-independent bitmap from a file
------------------------------------------------------------------------------

Syntax
ReadDIB( <cFile> )   -->   cDIB

Arguments
<cFile> is the name of the file.  If no path is specified,
Windows searches some pre-defined directories (usually, the
directory containing the running application and the Windows
directory).

Returns
If the file is found and is of the correct format, the bitmap
is returned.  If an error is detected, NIL is returned.

Description
This function can be used to read a device-independent bitmap,
ready to be displayed using ShowDIB(), or placed in the
clipboard using SetClipbData().

If you have a PCX file, you can use the Paintbrush program to
read it, and then use File...Save As to save it as a bitmap in
the correct format.

Example
// since Top and Left are always 0, they are unused
#define W_LEFT      1
#define W_TOP       2
#define W_RIGHT     3
#define W_BOTTOM    4

hDC := GetDC( hWnd )
cDIB := ReadDIB( "clip4win.bmp" )
aDIBRect := GetDIBRect( cDIB )
aClientRect := GetClientRect( hWnd )
// this will centre the bitmap in the window
ShowDIB( hDC, cDIB, (aClientRect[W_RIGHT] - aDIBRect[W_RIGHT]) / 2, ;
                    (aClientRect[W_BOTTOM] - aDIBRect[W_BOTTOM]) / 2 )
ReleaseDC( hWnd, hDC )


See Also: GetDIBRect() ShowDIB()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson