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


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

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


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

示例1: convertGdiplusBitmap

Surface8u convertGdiplusBitmap( Gdiplus::Bitmap &bitmap )
{	
	Gdiplus::BitmapData bitmapData;
	Gdiplus::Rect rect( 0, 0, bitmap.GetWidth(), bitmap.GetHeight() );

	Gdiplus::PixelFormat requestedFormat = bitmap.GetPixelFormat();
	SurfaceChannelOrder sco;
	bool premult;
	gdiplusPixelFormatToSurfaceChannelOrder( requestedFormat, &sco, &premult );
	if( sco == SurfaceChannelOrder::UNSPECIFIED ) {
		UINT flags = bitmap.GetFlags();
		sco = ( flags & Gdiplus::ImageFlagsHasAlpha ) ? SurfaceChannelOrder::BGRA : SurfaceChannelOrder::BGR;
		requestedFormat = ( flags & Gdiplus::ImageFlagsHasAlpha ) ? PixelFormat32bppARGB : PixelFormat24bppRGB;
	}
	
	bitmap.LockBits( &rect, Gdiplus::ImageLockModeRead, requestedFormat, &bitmapData );
	Surface8u result( bitmap.GetWidth(), bitmap.GetHeight(), sco.hasAlpha(), sco );

	const uint8_t *srcDataBase = (uint8_t*)bitmapData.Scan0;
	int32_t width = bitmap.GetWidth();
	for( uint32_t y = 0; y < bitmap.GetHeight(); ++y ) {
		memcpy( result.getData( Vec2i( 0, y ) ), srcDataBase + y * bitmapData.Stride, width * result.getPixelInc() );
	}

	bitmap.UnlockBits( &bitmapData );
	return result;
}
开发者ID:timmb,项目名称:HarmonicMotion,代码行数:27,代码来源:CinderMswGdiPlus.cpp

示例2: DrawTexturedRect

		void GDIPlus::DrawTexturedRect( Gwen::Texture* pTexture, Gwen::Rect pTargetRect, float u1, float v1, float u2, float v2 )
		{
			Gdiplus::Bitmap* pImage = (Gdiplus::Bitmap*) pTexture->data;

			// Missing image, not loaded properly?
			if ( !pImage || pImage->GetType() == Gdiplus::ImageTypeUnknown ) 
				return DrawMissingImage( pTargetRect );

			Translate( pTargetRect );

			Gdiplus::RectF TargetRect( pTargetRect.x, pTargetRect.y, pTargetRect.w, pTargetRect.h );

			// Convert UV to pixel coords
			float fW = pImage->GetWidth();
			float fH = pImage->GetHeight();

			u1 *= fW;
			v1 *= fH;

			u2 *= fW;
			u2 -= u1;

			v2 *= fH;
			v2 -= v1;

			graphics->DrawImage( pImage, TargetRect, u1, v1, u2, v2, Gdiplus::UnitPixel );
			
		}
开发者ID:charliesome,项目名称:battlecars,代码行数:28,代码来源:GDIPlus.cpp

示例3: convertGdiplusBitmap

Surface8u convertGdiplusBitmap( Gdiplus::Bitmap &bitmap, bool premultiplied )
{	
	Gdiplus::BitmapData bitmapData;
	Gdiplus::Rect rect( 0, 0, bitmap.GetWidth(), bitmap.GetHeight() );
	bitmap.LockBits( &rect, Gdiplus::ImageLockModeRead, (premultiplied) ? PixelFormat32bppPARGB : PixelFormat32bppARGB, &bitmapData );
	Surface8u result( bitmap.GetWidth(), bitmap.GetHeight(), true, SurfaceChannelOrder::BGRA );

	const uint8_t *srcDataBase = (uint8_t*)bitmapData.Scan0;
	int32_t width = bitmap.GetWidth();
	for( uint32_t y = 0; y < bitmap.GetHeight(); ++y ) {
		memcpy( result.getData( Vec2i( 0, y ) ), srcDataBase + y * bitmapData.Stride, width * 4 );
	}

	bitmap.UnlockBits( &bitmapData );
	return result;
}
开发者ID:AaronMeyers,项目名称:Cinder,代码行数:16,代码来源:CinderMswGdiPlus.cpp

示例4: 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 );
}
开发者ID:vladios13,项目名称:image-uploader,代码行数:30,代码来源:Utils.cpp

示例5: getImagePropertiesHelper

static void getImagePropertiesHelper(vl::ImageShape & shape, Gdiplus::Bitmap & bitmap)
{
  bool grayscale = (bitmap.GetFlags() & ImageFlagsColorSpaceGRAY) ;
  shape.width = bitmap.GetWidth() ;
  shape.height = bitmap.GetHeight() ;
  shape.depth = grayscale ? 1 : 3 ;
}
开发者ID:Alululululululu,项目名称:CNN-for-Image-Retrieval,代码行数:7,代码来源:imread_gdiplus.cpp

示例6: GetIconicRepresentation

HBITMAP TaskbarWnd::GetIconicRepresentation(int nWidth, int nHeight, int scale )
{
    HRESULT hr = E_FAIL;

	Gdiplus::Bitmap* src = Gdiplus::Bitmap::FromHBITMAP( hbm_cached_,0);

	// scale
	Gdiplus::Bitmap  dest( nWidth, nHeight, PixelFormat32bppARGB);
	{
		Gdiplus::RectF rDest(0,0,(Gdiplus::REAL)nWidth, (Gdiplus::REAL)nHeight );
		Gdiplus::Graphics gScale( &dest );

		if ( scale != 1 )
		{
			nWidth  = std::min(nWidth*scale, (int)src->GetWidth());
			nHeight = std::min(nHeight*scale, (int)src->GetHeight());
		}

		gScale.DrawImage( src, rDest,0,0,(Gdiplus::REAL)nWidth,(Gdiplus::REAL)nHeight, Gdiplus::UnitPixel, NULL, NULL, NULL );

	}
	delete src;

	// retval and cleanup
	HBITMAP hBitmap = 0;
	dest.GetHBITMAP(Gdiplus::Color::Black, &hBitmap);
    return hBitmap;
}
开发者ID:littlemole,项目名称:moe,代码行数:28,代码来源:taskbar.cpp

示例7: LoadTexture

		void GDIPlus::LoadTexture( gwen::Texture* pTexture )
		{
			Gdiplus::Bitmap* pImage = new Gdiplus::Bitmap( pTexture->name.GetUnicode().c_str() );
			pTexture->data = pImage;
			pTexture->width = pImage->GetWidth();
			pTexture->height = pImage->GetHeight();
		}
开发者ID:MegaThorx,项目名称:GWEN,代码行数:7,代码来源:GDIPlus.cpp

示例8: MakeIcon

void MakeIcon(HICON icon, char* path) {
  Gdiplus::Bitmap* bitmap = Gdiplus::Bitmap::FromFile(ToWChar(path));
  if (bitmap->GetWidth()) {
    bitmap->GetHICON(&icon);
    delete bitmap;
  }
}
开发者ID:alxpborges,项目名称:appjs,代码行数:7,代码来源:native_window_win.cpp

示例9: get_img_size

void gdiplus_container::get_img_size( litehtml::uint_ptr img, litehtml::size& sz )
{
	Gdiplus::Bitmap* bmp = (Gdiplus::Bitmap*) img;
	if(bmp)
	{
		sz.width	= bmp->GetWidth();
		sz.height	= bmp->GetHeight();
	}
}
开发者ID:CarterTsai,项目名称:litehtml,代码行数:9,代码来源:gdiplus_container.cpp

示例10: ExtractBitmap

    Bitmap CanvasGdiplus::ExtractBitmap() const
    {
        DCHECK(!mem_bitmap_.IsNull());

        // 生成一个位图, 绘制画布内容到其中并返回.
        Gdiplus::Bitmap* bitmap = mem_bitmap_.GetNativeBitmap();
        Gdiplus::Rect rc_bitmap(0, 0, bitmap->GetWidth(), bitmap->GetHeight());
        return Bitmap(bitmap->Clone(rc_bitmap, bitmap->GetPixelFormat()));
    }
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:9,代码来源:canvas_gdiplus.cpp

示例11: OnFileNameChange

//-------------------------------------------------------------------------------------
void DlgOpenImage::OnFileNameChange()
{
    m_thumb.ApplyEffect (FCEffectFillColor(FCColor(255,255,255))) ;

    CString   szFile = GetPathName() ;

    FCImageProperty   prop ;
    CSize   sizeImage (0,0) ;

    if (PathFileExists(szFile))
    {
        IMAGE_TYPE  imgType = FCImageCodecFactory::GetTypeByFileExt(szFile) ;

        if ( (imgType == IMG_JPG) ||
             (imgType == IMG_BMP) ||
             (imgType == IMG_PNG) ||
             (imgType == IMG_TIF) ||
             (imgType == IMG_GIF) )
        {
            Gdiplus::Bitmap   bmp (szFile) ;
            if (bmp.GetLastStatus() == Gdiplus::Ok)
            {
                sizeImage = CSize (bmp.GetWidth(), bmp.GetHeight()) ;
                FCImageCodec_Gdiplus::GetPropertyFromBitmap(bmp, prop) ;

                // calculate thumb size
                CRect   rc (0, 0, m_thumb.Width(), m_thumb.Height()) ;
                rc = FCObjGraph::CalcFitWindowSize (sizeImage, rc) ;

                FCImageDrawDC   memDC (m_thumb) ;
                Gdiplus::Graphics(memDC).DrawImage (&bmp, rc.left, rc.top, rc.Width(), rc.Height()) ;
            }
        }
    }

    // update size
    CString   s ;
    if (sizeImage.cx && sizeImage.cy)
    {
        s.Format(L"%d x %d", sizeImage.cx, sizeImage.cy) ;
        s = L"Size :" + s ;
    }
    SetDlgItemText(IDC_SIZE_VALUE, s) ;

    // update date
    s = L"" ;
    if (prop.m_ExifDTOrig.length())
    {
        s = L"Date :" + CString(prop.m_ExifDTOrig.c_str()) ;
    }
    SetDlgItemText(IDC_DATE_VALUE, s) ;

    m_ctrl.Invalidate() ;
}
开发者ID:ohosrry,项目名称:wtldemo,代码行数:55,代码来源:dlg_open_image.cpp

示例12: read

view::pixel_t* read(wchar_t *filename){
	Gdiplus::Bitmap *bmp = Gdiplus::Bitmap::FromFile(filename);
	if (bmp->GetLastStatus() != Gdiplus::Ok) return 0;

	Gdiplus::Rect r;
	r.X = 0;
	r.Y = 0;
	r.Width = bmp->GetWidth();
	r.Height = bmp->GetHeight();

	Gdiplus::BitmapData data;
	bmp->LockBits(&r, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &data);

	return (view::pixel_t*)data.Scan0;
}
开发者ID:Jasper-Bekkers,项目名称:krryn-ui,代码行数:15,代码来源:main.cpp

示例13: CLOG

Meter::Meter(std::wstring bitmapName, int x, int y, int units) :
_value(0.0f),
_drawnValue(-1.0f),
_units(units),
_drawnUnits(-1) {
    _rect.X = x;
    _rect.Y = y;

    Gdiplus::Bitmap *bmp = Gdiplus::Bitmap::FromFile(
        bitmapName.c_str(), false);
    CLOG(L"Loading meter bitmap: %s\nStatus: %d",
        bitmapName.c_str(), bmp->GetLastStatus());
    _bitmap = bmp;

    _rect.Width = bmp->GetWidth();
    _rect.Height = bmp->GetHeight();
}
开发者ID:pipetko,项目名称:3RVX,代码行数:17,代码来源:Meter.cpp

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

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


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