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


C++ Bitmap::GetPixel方法代码示例

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


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

示例1: 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() );
		}
开发者ID:charliesome,项目名称:battlecars,代码行数:10,代码来源:GDIPlus.cpp

示例2: 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

示例3: GetCharMaxX

//---------------------------------------------------------------------------
int GetCharMaxX(Gdiplus::Bitmap& charBitmap)
{
    using namespace Gdiplus;

	int width  = charBitmap.GetWidth();
	int height = charBitmap.GetHeight();

	for(int x = width-1; x >= 0; --x)
	{
		for(int y = 0; y < height; ++y)
		{
			Color color;
			charBitmap.GetPixel(x, y, &color);
			if(color.GetAlpha() > 0)
			{
				 return x;
			}
		}
	}

	return width-1;
}
开发者ID:Anters,项目名称:LevelEditor,代码行数:23,代码来源:Font.cpp

示例4: Load

//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
bool PngTextureLoader::Load(void* data, int32_t size, bool rev)
{
#if __PNG_DDI
	auto global = GlobalAlloc(GMEM_MOVEABLE,size);
	auto buf = GlobalLock(global);
	CopyMemory(buf, data, size);
	GlobalUnlock(global);
	LPSTREAM stream = NULL;
	CreateStreamOnHGlobal( global, false, &stream);
	Gdiplus::Bitmap* bmp = Gdiplus::Bitmap::FromStream(stream);
	ES_SAFE_RELEASE(stream);
	GlobalFree(global);


	if( bmp != NULL && bmp->GetLastStatus() == Gdiplus::Ok )
	{
		textureWidth = bmp->GetWidth();
		textureHeight = bmp->GetHeight();
		textureData.resize(textureWidth * textureHeight * 4);

		if(rev)
		{
			for(auto y = 0; y < textureHeight; y++ )
			{
				for(auto x = 0; x < textureWidth; x++ )
				{
					Gdiplus::Color  color;
					bmp->GetPixel(x, textureHeight - y - 1, &color);

					textureData[(x + y * textureWidth) * 4 + 0] = color.GetR();
					textureData[(x + y * textureWidth) * 4 + 1] = color.GetG();
					textureData[(x + y * textureWidth) * 4 + 2] = color.GetB();
					textureData[(x + y * textureWidth) * 4 + 3] = color.GetA();
				}
			}
		}
		else
		{
			for(auto y = 0; y < textureHeight; y++ )
			{
				for(auto x = 0; x < textureWidth; x++ )
				{
					Gdiplus::Color  color;
					bmp->GetPixel(x, y, &color);

					textureData[(x + y * textureWidth) * 4 + 0] = color.GetR();
					textureData[(x + y * textureWidth) * 4 + 1] = color.GetG();
					textureData[(x + y * textureWidth) * 4 + 2] = color.GetB();
					textureData[(x + y * textureWidth) * 4 + 3] = color.GetA();
				}
			}
		}
		
		return true;
	}
	else
	{
		ES_SAFE_DELETE(bmp);
		return false;
	}
#else
	uint8_t* data_ = (uint8_t*) data;

	/* pngアクセス構造体を作成 */
	png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
	
	/* リードコールバック関数指定 */
	png_set_read_fn(png, &data_, &PngReadData);

	/* png画像情報構造体を作成 */
	png_infop png_info = png_create_info_struct(png);

	/* エラーハンドリング */
	if (setjmp(png_jmpbuf(png)))
	{
		png_destroy_read_struct(&png, &png_info, NULL);
		return false;
	}

	/* IHDRチャンク情報を取得 */
	png_read_info(png, png_info);
	png_uint_32 width, height;
	int bit_depth, color_type, interlace_type, comp_type, filter_type;
	png_get_IHDR(png, png_info, &width, &height, &bit_depth, &color_type, &interlace_type,
				 &comp_type, &filter_type);

	/* RGBA8888フォーマットに変換する */
	if (bit_depth < 8)
	{
		png_set_packing(png);
	}
	else if (bit_depth == 16)
	{
		png_set_strip_16(png);
	}

	uint32_t pixelBytes = 4;
//.........这里部分代码省略.........
开发者ID:hirakuni45,项目名称:glfw3_app,代码行数:101,代码来源:PngTextureLoader.cpp

示例5: OnPaint

void CListViewNode::OnPaint(Gdiplus::Graphics* graphics, INT xPos, INT yPos, INT cBottom, INT cRight)
{
	if ( !m_listView )
		return;

	RECT iconRect; ::CopyRect(&iconRect, &m_iconRect); ::OffsetRect(&iconRect, -xPos, -yPos);
	RECT textRect; ::CopyRect(&textRect, &m_textRect); ::OffsetRect(&textRect, -xPos, -yPos);
	RECT borderRect; ::CopyRect(&borderRect, &m_borderRect); borderRect.right = borderRect.left + cRight; ::OffsetRect(&borderRect, 0, -yPos);
	
	if ( iconRect.bottom < 0 )
		return;
	if ( iconRect.top >= cBottom )
		return;

	Gdiplus::Font* pFont = NULL;
	Gdiplus::Brush* pBrushBackground = NULL;
	Gdiplus::Brush* pBrushForeground = NULL;

	if ( m_selected )
	{
		pFont = m_listView->get_Font(_T(".Font.Selected"), _T("ListView"));
		pBrushBackground = m_listView->get_Brush(_T(".BackgroundColor.Selected"), _T("ListView"), Gdiplus::Color::Blue);
		pBrushForeground = m_listView->get_Brush(_T(".ForegroundColor.Selected"), _T("ListView"), Gdiplus::Color::White);
	}
	else
	{
		pFont = m_listView->get_Font(_T(".Font.Normal"), _T("ListView"));
		pBrushBackground = m_listView->get_Brush(_T(".BackgroundColor.Normal"), _T("ListView"), Gdiplus::Color::White);
		pBrushForeground = m_listView->get_Brush(_T(".ForegroundColor.Normal"), _T("ListView"), Gdiplus::Color::Black);
	}

	Gdiplus::RectF iconRectF; Convert2RectF(&iconRectF, &iconRect);
	Gdiplus::RectF textRectF; Convert2RectF(&textRectF, &textRect);
	Gdiplus::RectF borderRectF; Convert2RectF(&borderRectF, &borderRect);
	Gdiplus::PointF pt; pt.X = textRectF.X; pt.Y = textRectF.Y;

	graphics->FillRectangle(pBrushBackground, borderRectF);

	Gdiplus::Bitmap* image = NULL;
	UINT hImage = 0;

	if ( (m_imageIndex >= 0) && (((dword)m_imageIndex) < m_listView->get_ImageCount()) )
		image = m_listView->get_Image(m_imageIndex);
	if ( image && (image->GetHeight() > 0) )
		hImage = image->GetHeight();
	if ( hImage > 0 )
	{
		Gdiplus::Color transparentcolor;
		Gdiplus::ImageAttributes imAtt;

		image->GetPixel(0, hImage - 1, &transparentcolor);
		imAtt.SetColorKey(transparentcolor, transparentcolor, Gdiplus::ColorAdjustTypeBitmap);

		graphics->DrawImage(image, iconRectF, 0.0, 0.0, Cast(Gdiplus::REAL,hImage), Cast(Gdiplus::REAL,hImage), Gdiplus::UnitPixel, &imAtt);
	}
	if ( !(m_text.IsEmpty()) )
		graphics->DrawString(m_text.GetString(), m_textDisplayLength, pFont, pt, Gdiplus::StringFormat::GenericTypographic(), pBrushForeground);
	if ( m_focused )
	{
		Gdiplus::Pen grayPen(Gdiplus::Color::Gray);
		grayPen.SetDashStyle(Gdiplus::DashStyleDot);

		graphics->DrawRectangle(&grayPen, textRectF);
	}
}
开发者ID:okdevdo,项目名称:UserLib,代码行数:65,代码来源:ListView.cpp


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