//=================================================================
//
// Copyright (c) Microsoft Corporation 1999 - All Rights Reserved.
//
//=================================================================

#include <windows.h>
#include <windowsx.h>
#include <assert.h>
#include <ddraw.h>

#include "color.h"

//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
DWORD GetPixelFormat(DDPIXELFORMAT *ddpf)
{
    if (ddpf->dwRGBBitCount == 8 && (ddpf->dwFlags & DDPF_PALETTEINDEXED8))
    {
        return 8;
    }
    else if ((ddpf->dwFlags&DDPF_ALPHAPIXELS) &&
			 ddpf->dwRGBBitCount == 16 &&
             ddpf->dwRBitMask == 0x7C00 &&
             ddpf->dwGBitMask == 0x03E0 &&
             ddpf->dwBBitMask == 0x001F &&
             ddpf->dwRGBAlphaBitMask == 0x8000)
    {
        return 1555;
    }
    else if (ddpf->dwRGBBitCount == 16 &&
             ddpf->dwRBitMask == 0x7C00 &&
             ddpf->dwGBitMask == 0x03E0 &&
             ddpf->dwBBitMask == 0x001F)
    {
        return 555;
    }
    else if (ddpf->dwRGBBitCount == 16 &&
             ddpf->dwRBitMask == 0xF800 &&
             ddpf->dwGBitMask == 0x07E0 &&
             ddpf->dwBBitMask == 0x001F)
    {
        return 565;
    }
    else if ((ddpf->dwFlags&DDPF_ALPHAPIXELS) &&
			 ddpf->dwRGBBitCount == 16 &&
             ddpf->dwRBitMask == 0x0F00 &&
             ddpf->dwGBitMask == 0x00F0 &&
             ddpf->dwBBitMask == 0x000F &&
             ddpf->dwRGBAlphaBitMask == 0xF000)
    {
        return 4444;
    }
    else if (ddpf->dwRGBBitCount == 32 &&
             ddpf->dwRBitMask == 0x00FF0000 &&
             ddpf->dwGBitMask == 0x0000FF00 &&
             ddpf->dwBBitMask == 0x000000FF)
    {
        return 32;
    }
    else
    {
        return 0;
    }
}

