Again. the code attached is wholesale from my program... but it should work for just some minor chances... I assume u packed your image data into DIB... if u are not sure about that... there are quite a few good examples in the code area.

I've actually got the code from some of these examples too.


BOOL CDib:raw ( CDC* dc, const CRect* rcDst, const CRect* rcSrc, CPalette* pPal )
{
CRect DCRect(Rect());
if ( rcDst )
DCRect = *rcDst;

CRect DibRect (Rect());
if ( rcSrc )
DibRect = *rcSrc;

CPalette pal;
pal.Attach(m_Pal);
CPalette* pPalette = NULL;

int Swap = DibRect.top;
DibRect.top = DibRect.bottom+1;
DibRect.bottom = Swap+1;

if ( pPal )
pPalette = pPal;
else
pPalette = &pal;

BOOL bSuccess = :rawDIB(dc->m_hDC, &DCRect, m_hDib, &DibRect, pPalette);
pal.Detach();
return bSuccess;
}


/*-------------------------------
| Macro |
-------------------------------*/

/* 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)


BOOL WINAPI DrawDIB ( HDC hDC,
LPRECT lpDCRect,
HDIB hDIB,
LPRECT lpDIBRect,
CPalette* pPal )
{
/* Determine whether to stretch */
if ( (RECTWIDTH(lpDCRect) == RECTWIDTH(lpDIBRect) ) &&
(RECTHEIGHT(lpDCRect) == RECTHEIGHT(lpDIBRect) ) )
{
return PaintDIB(hDC,lpDCRect,hDIB,lpDIBRect,pPal,FALSE);
}
else
{
return PaintDIB(hDC,lpDCRect,hDIB,lpDIBRect,pPal,TRUE);
}
}


BOOL WINAPI PaintDIB ( HDC hDC,
LPRECT lpDCRect,
HDIB hDIB,
LPRECT lpDIBRect,
CPalette* pPal,
BOOL bStretch )
{
LPSTR lpDIBHdr; // Pointer to BITMAPINFOHEADER
LPSTR lpDIBBits; // Pointer to DIB bits
BOOL bSuccess=FALSE; // Success/fail flag
HPALETTE hPal=NULL; // Our DIB's palette
HPALETTE hOldPal=NULL; // Previous palette

/* Check for valid DIB handle */
if ( hDIB == NULL )
return FALSE;

/* Lock down the DIB, and get a pointer to the beginning of the bit
* buffer
*/
lpDIBHdr = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);
lpDIBBits = ::FindDIBBits(lpDIBHdr);

// Get the DIB's palette, then select it into DC
if ( pPal != NULL )
{
hPal = (HPALETTE) pPal->m_hObject;

hOldPal = ::SelectPalette(hDC, hPal, FALSE);
::RealizePalette(hDC);
}

/* Microsoft version always uses ::SetStretchBltMode(hDC, COLORONCOLOR); */
/* Make sure to use the stretching mode best for color pictures */
::SetStretchBltMode(hDC, COLORONCOLOR);

// Determine whether to call StretchDIBits() or SetDIBitsToDevice() */
if ( bStretch == FALSE )
bSuccess = ::SetDIBitsToDevice( hDC, // hDC
lpDCRect->left, // DestX
lpDCRect->top, // DestY
RECTWIDTH(lpDCRect), // nDestWidth
RECTHEIGHT(lpDCRect), // nDestHeight
lpDIBRect->left, // SrcX
(int)DIBHeight(lpDIBHdr) -
lpDIBRect->top -
RECTHEIGHT(lpDIBRect), // SrcY
0, // nStartScan
(WORD)DIBHeight(lpDIBHdr), // nNumScans
lpDIBBits, // lpBits
(LPBITMAPINFO)lpDIBHdr, // lpBitsInfo
DIB_RGB_COLORS); // wUsage
else
{
bSuccess = ::StretchDIBits ( hDC, // hDC
lpDCRect->left, // DestX
lpDCRect->top, // DestY
RECTWIDTH(lpDCRect), // nDestWidth
RECTHEIGHT(lpDCRect), // nDestHeight
lpDIBRect->left, // SrcX
lpDIBRect->top, // SrcY
RECTWIDTH(lpDIBRect), // wSrcWidth
RECTHEIGHT(lpDIBRect), // wSrcHeight
lpDIBBits, // lpBits
(LPBITMAPINFO)lpDIBHdr, // lpBitsInfo
DIB_RGB_COLORS, // wUsage
SRCCOPY); // dwROP
}
::GlobalUnlock((HGLOBAL) hDIB);

/* Reselect old palette */
if ( hOldPal != NULL )
{
::SelectPalette(hDC, hOldPal,FALSE);
::RealizePalette(hDC);
}

return bSuccess;
}