// hack for stupid GDIplus void Gdip_RemoveAlpha(Gdiplus::Bitmap& source, Gdiplus::Color color ) { using namespace Gdiplus; Rect r( 0, 0, source.GetWidth(),source.GetHeight() ); BitmapData bdSrc; source.LockBits( &r, ImageLockModeRead , PixelFormat32bppARGB,&bdSrc); BYTE* bpSrc = (BYTE*)bdSrc.Scan0; //bpSrc += (int)sourceChannel; for ( int i = r.Height * r.Width; i > 0; i-- ) { BGRA_COLOR * c = (BGRA_COLOR *)bpSrc; if(c->a!=255) { //c = 255; DWORD * d= (DWORD*)bpSrc; *d= color.ToCOLORREF(); c ->a= 255; } bpSrc += 4; } source.UnlockBits( &bdSrc ); }
void TextRenderHdc::SetTextColor(Gdiplus::Color col) { CrashIf(!hdc); if (textColor.GetValue() == col.GetValue()) { return; } textColor = col; ::SetTextColor(hdc, col.ToCOLORREF()); }
void TextRenderGdi::SetTextColor(Gdiplus::Color col) { if (textColor.GetValue() == col.GetValue()) { return; } textColor = col; if (hdcGfxLocked) { ::SetTextColor(hdcGfxLocked, col.ToCOLORREF()); } }
LRESULT CMainFrame::OnPenColor(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { // allow users to choose an arbitrary pen color Gdiplus::Color currentColor; m_view.m_Pen.GetColor(¤tColor); COLORREF color = currentColor.ToCOLORREF(); CColorDialog test(color); test.DoModal(); color = test.GetColor(); Gdiplus::Color newColor(GetRValue(color), GetGValue(color), GetBValue(color)); m_view.m_Pen.SetColor(newColor); return 0; }