src/leptwin.c
static LPBITMAPINFO
DSCreateBitmapInfo(l_int32 width,
                   l_int32 height,
                   l_int32 depth,
                   PIXCMAP *cmap)
{
l_int32       nInfoSize;
LPBITMAPINFO  pbmi;
LPDWORD       pMasks;

    nInfoSize = sizeof(BITMAPINFOHEADER);
    if( depth <= 8 )
        nInfoSize += sizeof(RGBQUAD) * (1 << depth);
    if((depth == 16) || (depth == 32))
        nInfoSize += (3 * sizeof(DWORD));
    
        /* Create the header big enough to contain color table and
         * bitmasks if needed. */
    pbmi = (LPBITMAPINFO)malloc(nInfoSize);
    if (!pbmi)
        return NULL;

    ZeroMemory(pbmi, nInfoSize);
    pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    pbmi->bmiHeader.biWidth = width;
    pbmi->bmiHeader.biHeight = height;
    pbmi->bmiHeader.biPlanes = 1;
    pbmi->bmiHeader.biBitCount = depth;

        /* override below for 16 and 32 bpp */
    pbmi->bmiHeader.biCompression = BI_RGB;

        /*  ?? not sure if this is right?  */
    pbmi->bmiHeader.biSizeImage = DSImageBitsSize(pbmi);

    pbmi->bmiHeader.biXPelsPerMeter = 0;
    pbmi->bmiHeader.biYPelsPerMeter = 0;
    pbmi->bmiHeader.biClrUsed = 0;	/* override below */
    pbmi->bmiHeader.biClrImportant = 0;

    switch(depth)
    {
        case 24:
                /* 24bpp requires no special handling */
            break;
        case 16:
                /* if it's 16bpp, fill in the masks and override the
                 * compression.  These are the default masks -- you
                 * could change them if needed. */
            pMasks = (LPDWORD)(pbmi->bmiColors);
            pMasks[0] = 0x00007c00;
            pMasks[1] = 0x000003e0;
            pMasks[2] = 0x0000001f;
            pbmi->bmiHeader.biCompression = BI_BITFIELDS;
            break;
        case 32:
                /* if it's 32 bpp, fill in the masks and override
                 * the compression */
            pMasks = (LPDWORD)(pbmi->bmiColors);
            /*pMasks[0] = 0x00ff0000; */
            /*pMasks[1] = 0x0000ff00; */
            /*pMasks[2] = 0x000000ff; */
            pMasks[0] = 0xff000000;
            pMasks[1] = 0x00ff0000;
            pMasks[2] = 0x0000ff00;

            pbmi->bmiHeader.biCompression = BI_BITFIELDS; 
            break;
        case 8:
        case 4:
        case 1:
            setColormap(pbmi, cmap);
            break;
    }
    return pbmi;
}
/* **********************************************************************
  HBITMAP DSCreateBitmapInfo(l_int32 width, l_int32 height, l_int32 depth, 
                             PIXCMAP *cmap)

  PARAMETERS:
    l_int32 width - Desired width of the DIBSection
    l_int32 height - Desired height of the DIBSection
    l_int32 depth - Desired bit-depth of the DIBSection
    PIXCMAP cmap - leptonica colormap for depths < 16

  RETURNS:
    LPBITMAPINFO - a ptr to BITMAPINFO of the desired size and bit-depth
                   NULL on failure
    
  REMARKS:
    Creates a BITMAPINFO based on the criteria passed in as parameters.

********************************************************************** */




a ptr to BITMAPINFO of the desired size and bit-depth
NULL on failure

Creates a BITMAPINFO based on the criteria passed in as parameters.
a ptr to BITMAPINFO of the desired size and bit - depth NULL on failure Creates a BITMAPINFO based on the criteria passed in as parameters .
static LPBITMAPINFO
DSCreateBitmapInfo(l_int32 width,
                   l_int32 height,
                   l_int32 depth,
                   PIXCMAP *cmap)
{
l_int32       nInfoSize;
LPBITMAPINFO  pbmi;
LPDWORD       pMasks;
    nInfoSize = sizeof(BITMAPINFOHEADER);
    if( depth <= 8 )
        nInfoSize += sizeof(RGBQUAD) * (1 << depth);
    if((depth == 16) || (depth == 32))
        nInfoSize += (3 * sizeof(DWORD));
    pbmi = (LPBITMAPINFO)malloc(nInfoSize);
    if (!pbmi)
        return NULL;
    ZeroMemory(pbmi, nInfoSize);
    pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    pbmi->bmiHeader.biWidth = width;
    pbmi->bmiHeader.biHeight = height;
    pbmi->bmiHeader.biPlanes = 1;
    pbmi->bmiHeader.biBitCount = depth;
    pbmi->bmiHeader.biCompression = BI_RGB;
    pbmi->bmiHeader.biSizeImage = DSImageBitsSize(pbmi);
    pbmi->bmiHeader.biXPelsPerMeter = 0;
    pbmi->bmiHeader.biYPelsPerMeter = 0;
    pbmi->bmiHeader.biClrUsed = 0;	
    pbmi->bmiHeader.biClrImportant = 0;
    switch(depth)
    {
        case 24:
            break;
        case 16:
            pMasks = (LPDWORD)(pbmi->bmiColors);
            pMasks[0] = 0x00007c00;
            pMasks[1] = 0x000003e0;
            pMasks[2] = 0x0000001f;
            pbmi->bmiHeader.biCompression = BI_BITFIELDS;
            break;
        case 32:
            pMasks = (LPDWORD)(pbmi->bmiColors);
            pMasks[0] = 0xff000000;
            pMasks[1] = 0x00ff0000;
            pMasks[2] = 0x0000ff00;
            pbmi->bmiHeader.biCompression = BI_BITFIELDS; 
            break;
        case 8:
        case 4:
        case 1:
            setColormap(pbmi, cmap);
            break;
    }
    return pbmi;
}
static LPBITMAPINFO DSCreateBitmapInfo ( l_int32 width , l_int32 height , l_int32 depth , PIXCMAP * cmap ) { l_int32 nInfoSize ; LPBITMAPINFO pbmi ; LPDWORD pMasks ; nInfoSize = sizeof ( BITMAPINFOHEADER ) ; if ( depth <= 8 ) nInfoSize += sizeof ( RGBQUAD ) * ( 1 << depth ) ; if ( ( depth == 16 ) || ( depth == 32 ) ) nInfoSize += ( 3 * sizeof ( DWORD ) ) ; pbmi = ( LPBITMAPINFO ) malloc ( nInfoSize ) ; if ( ! pbmi ) return NULL ; ZeroMemory ( pbmi , nInfoSize ) ; pbmi -> bmiHeader . biSize = sizeof ( BITMAPINFOHEADER ) ; pbmi -> bmiHeader . biWidth = width ; pbmi -> bmiHeader . biHeight = height ; pbmi -> bmiHeader . biPlanes = 1 ; pbmi -> bmiHeader . biBitCount = depth ; pbmi -> bmiHeader . biCompression = BI_RGB ; pbmi -> bmiHeader . biSizeImage = DSImageBitsSize ( pbmi ) ; pbmi -> bmiHeader . biXPelsPerMeter = 0 ; pbmi -> bmiHeader . biYPelsPerMeter = 0 ; pbmi -> bmiHeader . biClrUsed = 0 ; pbmi -> bmiHeader . biClrImportant = 0 ; switch ( depth ) { case 24 : break ; case 16 : pMasks = ( LPDWORD ) ( pbmi -> bmiColors ) ; pMasks [ 0 ] = 0x00007c00 ; pMasks [ 1 ] = 0x000003e0 ; pMasks [ 2 ] = 0x0000001f ; pbmi -> bmiHeader . biCompression = BI_BITFIELDS ; break ; case 32 : pMasks = ( LPDWORD ) ( pbmi -> bmiColors ) ; pMasks [ 0 ] = 0xff000000 ; pMasks [ 1 ] = 0x00ff0000 ; pMasks [ 2 ] = 0x0000ff00 ; pbmi -> bmiHeader . biCompression = BI_BITFIELDS ; break ; case 8 : case 4 : case 1 : setColormap ( pbmi , cmap ) ; break ; } return pbmi ; }
HBITMAP DSCreateBitmapInfo(l_int32 width, l_int32 height, l_int32 depth,
PIXCMAP *cmap)
HBITMAP DSCreateBitmapInfo ( l_int32 width l_int32 height l_int32 depth PIXCMAP * cmap )
/* Create the header big enough to contain color table and
         * bitmasks if needed. */ /* override below for 16 and 32 bpp */ /*  ?? not sure if this is right?  */ /* override below */ /* 24bpp requires no special handling */ /* if it's 16bpp, fill in the masks and override the
                 * compression.  These are the default masks -- you
                 * could change them if needed. */ /* if it's 32 bpp, fill in the masks and override
                 * the compression */ /*pMasks[0] = 0x00ff0000; */ /*pMasks[1] = 0x0000ff00; */ /*pMasks[2] = 0x000000ff; */