
/***************************************************************************
**
**    $Header:   
**
**    $Log:   
** 
****************************************************************************/

/////////////////////////////////////////////////////////////////////////////
//
//  File name:  DIBAPI.H
//
//  Description:The header file for the DIB APIs:
//
//      PaintDIB()          - Painting routine for a DIB
//      CreateDIBPalette()  - Creates a palette from a DIB
//      FindDIBBits()       - Returns a pointer to the DIB bits
//      DIBWidth()          - Gets the width of the DIB
//      DIBHeight()         - Gets the height of the DIB
//      PaletteSize()       - Gets the size required to store the DIB's palette
//      DIBNumColors()      - Calculates the number of colors
//                            in the DIB's color table
//      CopyHandle()        - Makes a copy of the given global memory block
//      SaveDIB()           - Saves the specified dib in a file
//      ReadDIBFile()       - Loads a DIB from a file
//
//  Author:     Roger Zhang
//
//  Date:       08/18/95
//
//  Modification:
//
//      1. 08/18/95, Initial version 
//
//
//  Copyright (C) 1995 Microtek International. All rights reserved.
//
/////////////////////////////////////////////////////////////////////////////


#ifndef _DIBAPI_
#define _DIBAPI_

/* Handle to a DIB */
DECLARE_HANDLE(HDIB);

/* DIB constants */
#define PALVERSION   0x300

/* DIB Macros*/

#define IS_WIN30_DIB(lpbi)  ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER))
#define RECTWIDTH(lpRect)     ((lpRect)->right - (lpRect)->left)
#define RECTHEIGHT(lpRect)    ((lpRect)->bottom - (lpRect)->top)

// WIDTHBYTES performs DWORD-aligning of DIB scanlines.  The "bits"
// parameter is the bit count for the scanline (biWidth * biBitCount),
// and this macro returns the number of DWORD-aligned bytes needed
// to hold those bits.

#define WIDTHBYTES(bits)    (((bits) + 31) / 32 * 4)


/* Function prototypes */
BOOL      WINAPI  PaintDIB (HDC, LPRECT, HDIB, LPRECT, CPalette* pPal);
BOOL      WINAPI  CreateDIBPalette(HDIB hDIB, CPalette* cPal);
LPSTR     WINAPI  FindDIBBits (LPSTR lpbi);
DWORD     WINAPI  DIBWidth (LPSTR lpDIB);
DWORD     WINAPI  DIBHeight (LPSTR lpDIB);
WORD      WINAPI  PaletteSize (LPSTR lpbi);
WORD      WINAPI  DIBNumColors (LPSTR lpbi);
HANDLE    WINAPI  CopyHandle (HANDLE h);

BOOL      WINAPI  SaveDIB (HDIB hDib, CFile& file);       

HDIB      WINAPI  ReadDIBFile(CFile& file);

#endif 

///////////////////////////////(EOF)/////////////////////////////////////////

