Esempio n. 1
0
_inline COLORREF MixRGBI(
    LPDWORD pal,
    BYTE    b0,
    BYTE    b1,
    BYTE    b2,
    BYTE    b3,
    int     x,
    int     y)
{
    if (((b0 == b1) && (b1 == b2) && (b2 == b3)) || ((x == 0) && (y == 0)))
        return RGBX(pal[b0]);
    else
        return MixRGB(pal[b0], pal[b1], pal[b2], pal[b3], x, y);
}
Esempio n. 2
0
void CStatusBarACT::OnPaint()
{
	if (m_crText == -1 && m_crFrom == -1 && m_crTo == -1)
	{
		Default();
	}
	else
	{
		CPaintDC dc(this);
		CRect rClient;
		CFont* pOldFont = dc.SelectObject(GetFont());

		GetClientRect(rClient);
		DrawRectBkgnd(&dc, rClient);

		int nPane = GetStatusBarCtrl().GetParts(0, NULL);
		dc.SetTextColor(m_crText);
		dc.SetBkMode(TRANSPARENT);

		while (nPane--)
		{
			CRect rect;
			GetItemRect(nPane, &rect);

			dc.TextOut(rect.left + 2, rect.top, GetPaneText(nPane));
			dc.ExcludeClipRect(rect); // so adjacent item cannot overwrite

			// draw divider
			if (nPane) // ignore first
			{
				rect.left -= 2;
				rect.right = rect.left + 1;
				rect.bottom -= 2;

				// pick color
				COLORREF color = m_crFrom;

				int nLum = RGBX(color).Luminance();
				color = (nLum < 128) ? GraphicsMisc::Lighter(m_crTo, 0.25) : GraphicsMisc::Darker(m_crTo, 0.75);
				dc.FillSolidRect(rect, color);
			}
		}

		dc.SelectObject(pOldFont);
	}
}
static dword* GetTexture(int i, byte* data)
{
	int x_offset = i*160;
    const byte brightness = 200;
    const byte bright_intensity = 55;
	for(int y = 0; y < 240; ++y)
	{
		for(int x = 0; x < 160; ++x)
		{
			byte r, g, b;
			byte c = data[y*320 + x + x_offset];
			byte i = c&8 ? brightness + bright_intensity : brightness;
			b = c&1 ? i : 0;
			r = c&2 ? i : 0;
			g = c&4 ? i : 0;
			dword* p = &tex[y*256 + x];
			*p = RGBX(r, g ,b);
		}
	}
	return tex;
}
Esempio n. 4
0
void GraphicsMisc::DrawSplitBar(CDC* pDC, const CRect& rSplitter, COLORREF crSplitBar, BOOL bEdged)
{
	BOOL bVert = (rSplitter.Height() > rSplitter.Width());
	DWORD dwEdges = (bEdged ? (bVert ? (GMDR_LEFT | GMDR_RIGHT) : (GMDR_TOP | GMDR_BOTTOM)) : 0);

	DrawRect(pDC, rSplitter, crSplitBar, Darker(crSplitBar, 0.2), 0, dwEdges);

	// draw drag marker (2 x 20)
	int nSplitWidth = min(rSplitter.Width(), rSplitter.Height());
	
	if (nSplitWidth > 2)
	{
		CRect rMarker(rSplitter);
		CPoint ptCentre = rMarker.CenterPoint();
		
		if (bVert)
		{
			rMarker.left = ptCentre.x - 1;
			rMarker.right = ptCentre.x + 1;

			rMarker.top = ptCentre.y - 10;
			rMarker.bottom = ptCentre.y + 10;
		}
		else // horizontal
		{
			rMarker.left = ptCentre.x - 10;
			rMarker.right = ptCentre.x + 10;
			
			rMarker.top = ptCentre.y - 1;
			rMarker.bottom = ptCentre.y + 1;
		}
		
		// use the splitter bkgnd luminance to decide whether
		// to draw the marker lighter or darker
		if (RGBX(crSplitBar).Luminance() > 128)
			pDC->FillSolidRect(rMarker, Darker(crSplitBar, 0.3));
		else
			pDC->FillSolidRect(rMarker, Lighter(crSplitBar, 0.3));
	}
}
Esempio n. 5
0
COLORREF GraphicsMisc::GetBestTextColor(COLORREF crBack)
{
	// base text color on luminance
	return (RGBX(crBack).Luminance() < 128) ? RGB(255, 255, 255) : 0;
}