// Gradient.cpp: implementation of the CGradient class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "Gradient.h" #include "math.h" CGradient::CGradient() { } CGradient::~CGradient() { } void CGradient::HorizontalGradient(CDC* pDC, LPRECT lpRect, COLORREF sColor, COLORREF eColor, BOOL bGamma, double gamma) { // Gradient params int width = lpRect->right - lpRect->left - 1; int height = lpRect->bottom - lpRect->top - 1; // Draw gradient HBRUSH hBrush = NULL; double percent; unsigned char red, green, blue; COLORREF color; RECT rect; for (int i=0; ileft + i + 1; rect.top = lpRect->top + 1; rect.right = rect.left + 1; rect.bottom = lpRect->bottom - 1; pDC->FillSolidRect(&rect, color); } } void CGradient::VerticalGradient(CDC* pDC, LPRECT lpRect, COLORREF sColor, COLORREF eColor, BOOL bGamma, double gamma) { // Gradient params int width = lpRect->right - lpRect->left - 1; int height = lpRect->bottom - lpRect->top - 1; // Draw gradient HBRUSH hBrush = NULL; double percent; unsigned char red, green, blue; COLORREF color; RECT rect; for (int i=0; ileft + 1; rect.top = lpRect->top + i + 1; rect.right = lpRect->right - 1; rect.bottom = rect.top + 1; pDC->FillSolidRect(&rect, color); } } void CGradient::HorizontalGradient(CDC* pDC, HRGN hRgn, COLORREF sColor, COLORREF eColor, BOOL bGamma, double gamma) { RECT rgnRect; GetRgnBox(hRgn, &rgnRect); // Gradient params int width = rgnRect.right - rgnRect.left - 1; int height = rgnRect.bottom - rgnRect.top - 1; // Draw gradient HBRUSH hBrush = NULL; unsigned char red, green, blue; COLORREF color; int startY, endY; RECT rect; bool foundStart, foundEnd; double rrate = (GetRValue(sColor)-GetRValue(eColor))*1.0/width; double grate = (GetGValue(sColor)-GetGValue(eColor))*1.0/width; double brate = (GetBValue(sColor)-GetBValue(eColor))*1.0/width; unsigned char sred = GetRValue(sColor); unsigned char sgreen = GetGValue(sColor); unsigned char sblue = GetBValue(sColor); for (int i=0; iFillSolidRect(&rect, color); } } } } void CGradient::VerticalGradient(CDC* pDC, HRGN hRgn, COLORREF sColor, COLORREF eColor, BOOL bGamma, double gamma) { RECT rgnRect; GetRgnBox(hRgn, &rgnRect); // Gradient params int width = rgnRect.right - rgnRect.left - 1; int height = rgnRect.bottom - rgnRect.top - 1; // Draw gradient HBRUSH hBrush = NULL; double percent; unsigned char red, green, blue; COLORREF color; int startX, endX; RECT rect; bool foundStart, foundEnd; double rrate = (GetRValue(sColor)-GetRValue(eColor))*1.0/height; double grate = (GetGValue(sColor)-GetGValue(eColor))*1.0/height; double brate = (GetBValue(sColor)-GetBValue(eColor))*1.0/height; unsigned char sred = GetRValue(sColor); unsigned char sgreen = GetGValue(sColor); unsigned char sblue = GetBValue(sColor); for (int i=0; iFillSolidRect(&rect, color); } } } }