本文整理汇总了C++中gdiplus::Color类的典型用法代码示例。如果您正苦于以下问题:C++ Color类的具体用法?C++ Color怎么用?C++ Color使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Color类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f
static void DrawFrame2(Graphics &g, RectI r)
{
g.SetCompositingQuality(CompositingQualityHighQuality);
g.SetSmoothingMode(SmoothingModeAntiAlias);
g.SetPageUnit(UnitPixel);
Font f(L"Impact", 40, FontStyleRegular);
CalcLettersLayout(g, &f, r.dx);
Gdiplus::Color bgCol;
bgCol.SetFromCOLORREF(WIN_BG_COLOR);
SolidBrush bgBrush(bgCol);
Rect r2(r.ToGdipRect());
r2.Inflate(1, 1);
g.FillRectangle(&bgBrush, r2);
Font f2(L"Impact", 16, FontStyleRegular);
DrawSumatraLetters(g, &f, &f2, 18.f);
if (gShowOptions)
return;
REAL msgY = (REAL)(r.dy / 2);
if (gMsg)
msgY += DrawMessage(g, gMsg, msgY, (REAL)r.dx, gMsgColor) + 5;
if (gMsgError)
DrawMessage(g, gMsgError, msgY, (REAL)r.dx, COLOR_MSG_FAILED);
}
示例2: TextOutline
void PngOutlineText::TextOutline(
Gdiplus::Color clrText,
Gdiplus::Color clrOutline,
int nThickness)
{
TextOutlineStrategy* pStrat = new TextOutlineStrategy();
pStrat->Init(clrText,clrOutline,nThickness);
if(m_pTextStrategy)
delete m_pTextStrategy;
m_pTextStrategy = pStrat;
TextOutlineStrategy* pStrat2 = new TextOutlineStrategy();
pStrat2->Init(
Gdiplus::Color(clrText.GetAlpha(),255,255,255),
Gdiplus::Color(clrOutline.GetAlpha(),255,255,255),
nThickness);
if(m_pTextStrategyMask)
delete m_pTextStrategyMask;
m_pTextStrategyMask = pStrat2;
}
示例3:
DirectionalLight::DirectionalLight(Gdiplus::Color colour, Vector3D direction)
{
_redIntensity = colour.GetRed();
_greenIntensity = colour.GetGreen();
_blueIntensity = colour.GetBlue();
_lightDirection = direction;
}
示例4: OnEraseBkgnd
BOOL CImgStatic::OnEraseBkgnd(CDC *pDC)
{
if (m_bZooming)
return TRUE;
if (m_bImageLoaded) {
RECT rc;
GetClientRect(&rc);
// Get Gdiplus graphics object
Gdiplus::Graphics grp(pDC->GetSafeHdc());
// Clear rectangle
Gdiplus::Color gdipColor;
gdipColor.SetFromCOLORREF(GetSysColor(COLOR_3DFACE));
Gdiplus::SolidBrush brush(gdipColor);
grp.FillRectangle(&brush, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
grp.Flush();
return TRUE;
} else {
return CStatic::OnEraseBkgnd(pDC);
}
}
示例5: GetHRgnFromPNG
HRGN CBtnRoundImg::GetHRgnFromPNG(CString strImagePath)
{
Gdiplus::Bitmap imageBaseRgn(strImagePath);
if (imageBaseRgn.GetLastStatus() != Ok)
{
ASSERT(FALSE);
return NULL;
}
HRGN hRgnTotal = ::CreateRectRgn(0, 0, 0, 0);
ASSERT(NULL != hRgnTotal);
Gdiplus::Color clrPixel; //ÏñËصÄÑÕÉ«
Gdiplus::Status stcGetClr; //״̬
for (int w = imageBaseRgn.GetWidth() - 1; w >= 0; w--)
{
for(int h = imageBaseRgn.GetHeight() - 1; h >= 0; h--)
{
stcGetClr = imageBaseRgn.GetPixel(w, h, &clrPixel);
ASSERT(stcGetClr == Ok);
int iAlpha = clrPixel.GetAlpha();
if (iAlpha == 0){
continue; //͸Ã÷É«²»´¦Àí
}
HRGN hRgnTemp = ::CreateRectRgn(w, h, w + 1, h + 1);
::CombineRgn(hRgnTotal, hRgnTotal, hRgnTemp, RGN_OR);
::DeleteObject(hRgnTemp);
}
}
return hRgnTotal;
}
示例6: OpenBitmapFromFile
void OpenBitmapFromFile(
const WCHAR *pFilename,
void **pBuffer,
uint32_t *width,
uint32_t *height)
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);
Bitmap *bitmap = new Bitmap(pFilename);
*width = bitmap->GetWidth();
*height = bitmap->GetHeight();
*pBuffer = new BYTE[*width * *height * 4]; // width * height * |RGBA|
// The folder 'stb_image' contains a PNG open/close module which
// is far less painful than this is, yo.
Gdiplus::Color clr;
for (uint32_t y = 0, idx = 0; y < *height; ++y)
{
for (uint32_t x = 0; x < *width; ++x, idx += 4)
{
bitmap->GetPixel(x, *height - y - 1, &clr);
((BYTE*)*pBuffer)[idx + 0] = clr.GetBlue();
((BYTE*)*pBuffer)[idx + 1] = clr.GetGreen();
((BYTE*)*pBuffer)[idx + 2] = clr.GetRed();
((BYTE*)*pBuffer)[idx + 3] = clr.GetAlpha();
}
}
delete bitmap;
bitmap = 0;
}
示例7: SetTextColor
void TextRenderHdc::SetTextColor(Gdiplus::Color col) {
CrashIf(!hdc);
if (textColor.GetValue() == col.GetValue()) {
return;
}
textColor = col;
::SetTextColor(hdc, col.ToCOLORREF());
}
示例8: PixelColour
Gwen::Color GDIPlus::PixelColour( Gwen::Texture* pTexture, unsigned int x, unsigned int y, const Gwen::Color& col_default )
{
Gdiplus::Bitmap* pImage = (Gdiplus::Bitmap*) pTexture->data;
if ( !pImage ) return col_default;
Gdiplus::Color c;
pImage->GetPixel( x, y, &c );
return Gwen::Color( c.GetR(), c.GetG(), c.GetB(), c.GetA() );
}
示例9:
void CSettingsRevisionGraphColors::ApplyColor
( CMFCColorButton& button
, CColors::GDIPlusColor color
, DWORD alpha)
{
COLORREF value = button.GetColor() == -1
? button.GetAutomaticColor()
: button.GetColor();
Gdiplus::Color temp;
temp.SetFromCOLORREF (value);
m_Colors.SetColor (color, (temp.GetValue() & 0xffffff) + (alpha << 24));
}
示例10: OnPenColor
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;
}
示例11: LoadPixel
//===============================================
void LoadPixel(UINT ofs, BYTE* rgba)
//===============================================
{
// get pixel of current image by offset ofs
UINT x,y;
Gdiplus::Color col;
PixelToCoord(ofs, &x, &y);
img->GetPixel(x,y, &col);
rgba[0] = col.GetR();
rgba[1] = col.GetG();
rgba[2] = col.GetB();
rgba[3] = col.GetA();
}
示例12: ColorsEqual
bool ColorsEqual(Gdiplus::Color a, Gdiplus::Color b)
{
return a.GetR() == b.GetR() &&
a.GetG() == b.GetG() &&
a.GetB() == b.GetB() &&
a.GetA() == b.GetA();
}
示例13: Extrude
void OutlineText::Extrude(
Gdiplus::Color color,
int nThickness,
Gdiplus::Point ptOffset)
{
ExtrudeStrategy* pStrat = new ExtrudeStrategy();
pStrat->Init(Gdiplus::Color(0,0,0,0),color,nThickness,ptOffset.X,ptOffset.Y);
m_clrShadow = color;
if(m_pFontBodyShadow)
delete m_pFontBodyShadow;
ExtrudeStrategy* pFontBodyShadow = new ExtrudeStrategy();
pFontBodyShadow->Init(Gdiplus::Color(color.GetA(),255,255),Gdiplus::Color(0,0,0,0),0,ptOffset.X,ptOffset.Y);
m_pFontBodyShadow = pFontBodyShadow;
if(m_pShadowStrategy)
delete m_pShadowStrategy;
m_ptShadowOffset = ptOffset;
m_pShadowStrategy = pStrat;
m_bExtrudeShadow = true;
m_bDiffuseShadow = false;
m_nShadowThickness = nThickness;
}
示例14: Gdip_RemoveAlpha
// 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 );
}
示例15: DiffusedShadow
void PngOutlineText::DiffusedShadow(
Gdiplus::Color color,
int nThickness,
Gdiplus::Point ptOffset)
{
DiffusedShadowStrategy* pStrat = new DiffusedShadowStrategy();
pStrat->Init(Gdiplus::Color(0,0,0,0),color,nThickness,false);
if(m_pShadowStrategy)
delete m_pShadowStrategy;
m_ptShadowOffset = ptOffset;
m_pShadowStrategy = pStrat;
DiffusedShadowStrategy* pStrat2 = new DiffusedShadowStrategy();
pStrat2->Init(
Gdiplus::Color(0,0,0,0),
Gdiplus::Color(color.GetAlpha(),255,255,255),
nThickness,
true);
if(m_pShadowStrategyMask)
delete m_pShadowStrategyMask;
m_pShadowStrategyMask = pStrat2;
m_clrShadow = color;
if(m_pFontBodyShadow)
delete m_pFontBodyShadow;
DiffusedShadowStrategy* pFontBodyShadow = new DiffusedShadowStrategy();
pFontBodyShadow->Init(Gdiplus::Color(255,255,255),Gdiplus::Color(0,0,0,0),nThickness,false);
m_pFontBodyShadow = pFontBodyShadow;
if(m_pFontBodyShadowMask)
delete m_pFontBodyShadowMask;
DiffusedShadowStrategy* pFontBodyShadowMask = new DiffusedShadowStrategy();
pFontBodyShadowMask->Init(Gdiplus::Color(color.GetAlpha(),255,255,255),Gdiplus::Color(0,0,0,0),
nThickness,false);
m_pFontBodyShadowMask = pFontBodyShadowMask;
m_bDiffuseShadow = true;
m_nShadowThickness = nThickness;
}