class CDib2 : public CDib 
{
public:
	BOOL Draw(CDC* pDC, CPoint ptDst, CSize sizeDst = CSize(-1,-1), 
		CPoint ptSrc = CPoint(0,0), CSize sizeSrc = CSize(-1,-1))
	{
		if(m_lpBMIH == NULL) return FALSE;
		if(m_hPalette != NULL)
			::SelectPalette(pDC->GetSafeHdc(), m_hPalette, TRUE);

		CSize sizeDim = GetDimensions();

		if (sizeDst == CSize(-1,-1)) sizeDst = sizeDim;
		if (sizeSrc == CSize(-1,-1)) sizeSrc = sizeDim;
		
		if (m_bStretchBlt)
		{
			pDC->SetStretchBltMode(COLORONCOLOR);
			::StretchDIBits(pDC->GetSafeHdc(), ptDst.x, ptDst.y, sizeDst.cx, sizeDst.cy,
				ptSrc.x, ptSrc.y, sizeSrc.cx, sizeSrc.cy,
				m_lpImage, (LPBITMAPINFO) m_lpBMIH, DIB_RGB_COLORS, SRCCOPY);
		}
		else
		{
			/*
			int SetDIBitsToDevice(
			  HDC hdc,                 // handle to DC
			  int XDest,               // x-coord of destination upper-left corner
			  int YDest,               // y-coord of destination upper-left corner 
			  DWORD dwWidth,           // source rectangle width
			  DWORD dwHeight,          // source rectangle height
			  int XSrc,                // x-coord of source lower-left corner
			  int YSrc,                // y-coord of source lower-left corner
			  UINT uStartScan,         // first scan line in array
			  UINT cScanLines,         // number of scan lines
			  CONST VOID *lpvBits,     // array of DIB bits
			  CONST BITMAPINFO *lpbmi, // bitmap information
			  UINT fuColorUse          // RGB or palette indexes
			);

			BOOL BitBlt(
			  HDC hdcDest, // handle to destination DC
			  int nXDest,  // x-coord of destination upper-left corner
			  int nYDest,  // y-coord of destination upper-left corner
			  int nWidth,  // width of destination rectangle
			  int nHeight, // height of destination rectangle
			  HDC hdcSrc,  // handle to source DC
			  int nXSrc,   // x-coordinate of source upper-left corner
			  int nYSrc,   // y-coordinate of source upper-left corner
			  DWORD dwRop  // raster operation code
			);
			*/

			::SetDIBitsToDevice(pDC->GetSafeHdc(), ptDst.x, ptDst.y, 
				sizeSrc.cx, sizeSrc.cy, //sizeDim.cx, sizeDim.cy,
				ptSrc.x, -ptSrc.y, 
				0, sizeDim.cy,
				m_lpImage, (LPBITMAPINFO) m_lpBMIH, DIB_RGB_COLORS); //m_hPalette != NULL ? DIB_PAL_COLORS : DIB_RGB_COLORS);
			/*
			::SetDIBitsToDevice(pDC->GetSafeHdc(), ptDst.x, ptDst.y, 
				sizeSrc.cx, sizeSrc.cy,
				ptSrc.x, 0, ptSrc.y, sizeDst.cy,
				m_lpImage, (LPBITMAPINFO) m_lpBMIH, DIB_RGB_COLORS); //m_hPalette != NULL ? DIB_PAL_COLORS : DIB_RGB_COLORS);
			*/
		}
		return TRUE;
	}
};