当前位置: 首页>>代码示例>>C++>>正文


C++ Color::GetAlpha方法代码示例

本文整理汇总了C++中gdiplus::Color::GetAlpha方法的典型用法代码示例。如果您正苦于以下问题:C++ Color::GetAlpha方法的具体用法?C++ Color::GetAlpha怎么用?C++ Color::GetAlpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gdiplus::Color的用法示例。


在下文中一共展示了Color::GetAlpha方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;

}
开发者ID:Olivki,项目名称:foo-wsh-panel-mod,代码行数:25,代码来源:PngOutlineText.cpp

示例2: 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;
}
开发者ID:menpo,项目名称:mesa,代码行数:34,代码来源:utils.cpp

示例3: 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;
}
开发者ID:njustccy,项目名称:NjustTool,代码行数:34,代码来源:CBtnRoundImg.cpp

示例4: 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;
}
开发者ID:Olivki,项目名称:foo-wsh-panel-mod,代码行数:47,代码来源:PngOutlineText.cpp

示例5: GetCharMaxX

int DxFont::GetCharMaxX(Gdiplus::Bitmap & charBitmap)
{
    int width  = charBitmap.GetWidth( );
    int height = charBitmap.GetHeight( );

    for(int x = width - 1; x >= 0; --x )
    {
        for(int y = 0; y < height; ++y)
        {
            Gdiplus::Color color;

            charBitmap.GetPixel(x, y, &color);
            if( color.GetAlpha() > 0)
                return x;
        }
    }

    return width - 1;
}
开发者ID:quaikohc,项目名称:dx11framework,代码行数:19,代码来源:font_renderer_gdi.cpp

示例6: Initialize

void SpriteFont::Initialize(const wchar *fontName, float fontSize, UINT fontStyle, bool antiAliased, ID3D11Device *device) {
	m_size = fontSize;

	Gdiplus::TextRenderingHint hint = antiAliased ? Gdiplus::TextRenderingHintAntiAliasGridFit : Gdiplus::TextRenderingHintSingleBitPerPixelGridFit;

	// Init GDI+
	ULONG_PTR token = NULL;
	Gdiplus::GdiplusStartupInput startupInput(NULL, true, true);
	Gdiplus::GdiplusStartupOutput startupOutput;
	HR(GdiplusStartup(&token, &startupInput, &startupOutput));

	// Create the font
	Gdiplus::Font font(fontName, fontSize, fontStyle, Gdiplus::UnitPixel, NULL);

	// Check for error during construction
	HR(font.GetLastStatus());

	// Create a temporary Bitmap and Graphics for figuring out the rough size required
	// for drawing all of the characters
	int size = static_cast<int>(fontSize * NumChars * 2) + 1;
	Gdiplus::Bitmap sizeBitmap(size, size, PixelFormat32bppARGB);
	HR(sizeBitmap.GetLastStatus());

	Gdiplus::Graphics sizeGraphics(&sizeBitmap);
	HR(sizeGraphics.GetLastStatus());
	HR(sizeGraphics.SetTextRenderingHint(hint));

	m_charHeight = font.GetHeight(&sizeGraphics) * 1.5f;

	wchar allChars[NumChars + 1];
	for (wchar i = 0; i < NumChars; ++i) {
		allChars[i] = i + StartChar;
	}
	allChars[NumChars] = 0;

	Gdiplus::RectF sizeRect;
	HR(sizeGraphics.MeasureString(allChars, NumChars, &font, Gdiplus::PointF(0, 0), &sizeRect));
	int numRows = static_cast<int>(sizeRect.Width / TexWidth) + 1;
	int texHeight = static_cast<int>(numRows * m_charHeight) + 1;

	// Create a temporary Bitmap and Graphics for drawing the characters one by one
	int tempSize = static_cast<int>(fontSize * 2);
	Gdiplus::Bitmap drawBitmap(tempSize, tempSize, PixelFormat32bppARGB);
	HR(drawBitmap.GetLastStatus());

	Gdiplus::Graphics drawGraphics(&drawBitmap);
	HR(drawGraphics.GetLastStatus());
	HR(drawGraphics.SetTextRenderingHint(hint));

	// Create a temporary Bitmap + Graphics for creating a full character set
	Gdiplus::Bitmap textBitmap(TexWidth, texHeight, PixelFormat32bppARGB);
	HR(textBitmap.GetLastStatus());

	Gdiplus::Graphics textGraphics(&textBitmap);
	HR(textGraphics.GetLastStatus());
	HR(textGraphics.Clear(Gdiplus::Color(0, 255, 255, 255)));
	HR(textGraphics.SetCompositingMode(Gdiplus::CompositingModeSourceCopy));

	// Solid brush for text rendering
	Gdiplus::SolidBrush brush(Gdiplus::Color(255, 255, 255, 255));
	HR(brush.GetLastStatus());

	// Draw all of the characters, and copy them to the full character set
	wchar charString [2];
	charString[1] = 0;
	int currentX = 0;
	int currentY = 0;
	for (uint64 i = 0; i < NumChars; ++i) {
		charString[0] = static_cast<wchar>(i + StartChar);

		// Draw the character
		HR(drawGraphics.Clear(Gdiplus::Color(0, 255, 255, 255)));
		HR(drawGraphics.DrawString(charString, 1, &font, Gdiplus::PointF(0, 0), &brush));

		// Figure out the amount of blank space before the character
		int minX = 0;
		for (int x = 0; x < tempSize; ++x) {
			for (int y = 0; y < tempSize; ++y) {
				Gdiplus::Color color;
				HR(drawBitmap.GetPixel(x, y, &color));
				if (color.GetAlpha() > 0) {
					minX = x;
					x = tempSize;
					break;
				}
			}
		}

		// Figure out the amount of blank space after the character
		int maxX = tempSize - 1;
		for (int x = tempSize - 1; x >= 0; --x) {
			for (int y = 0; y < tempSize; ++y) {
				Gdiplus::Color color;
				HR(drawBitmap.GetPixel(x, y, &color));
				if (color.GetAlpha() > 0) {
					maxX = x;
					x = -1;
					break;
				}
			}
//.........这里部分代码省略.........
开发者ID:RichieSams,项目名称:thehalflingproject,代码行数:101,代码来源:sprite_font.cpp


注:本文中的gdiplus::Color::GetAlpha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。