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


C++ gdiplus::Bitmap类代码示例

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


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

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

示例2: GDIPlusDecoder

static void GDIPlusDecoder(CStdValVector* data) {
	HGLOBAL hMem = ::GlobalAlloc(GMEM_FIXED, data->m_data->getLength());
	BYTE* pMem = (BYTE*)::GlobalLock(hMem);
	memcpy(pMem, data->m_data->getMemoryBase(), data->m_data->getLength());

	IStream* pIStream = 0;
	::CreateStreamOnHGlobal(hMem, FALSE, &pIStream);

	Gdiplus::Bitmap* pImgBitmap = Gdiplus::Bitmap::FromStream(pIStream);

	InitClsids();

	pIStream->Release();
	HRESULT hr = ::CreateStreamOnHGlobal(NULL, true, &pIStream);

	pImgBitmap->Save(pIStream, &s_bmpClsid, NULL);

	LARGE_INTEGER liTemp = {0};
	pIStream->Seek(liTemp, STREAM_SEEK_SET, NULL);
	
	STATSTG stats = {0};
	pIStream->Stat(&stats, 0);
	DWORD dwSize = (DWORD)stats.cbSize.QuadPart;

	delete data->m_data;
	data->m_data = new SkMemoryStream(dwSize);
	pIStream->Read((void *)data->m_data->getMemoryBase(), dwSize, NULL);

	::GlobalUnlock(hMem);
	::GlobalFree(hMem);
	pIStream->Release();

	delete pImgBitmap;
}
开发者ID:henryrao,项目名称:kdguigl,代码行数:34,代码来源:ResSkiaImage.cpp

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

示例4: LoadFromFile

bool CTuoImage::LoadFromFile(bool bPNG)
{
	std::wstring strPath;
	if (bPNG)
		strPath = g_strSkinDir + _T("\\") + m_strFileName + _T(".png");
	else
		strPath = g_strSkinDir + _T("\\") + m_strFileName + _T(".ico");

	Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromFile(strPath.c_str());
	if (pBitmap)
	{
		if (pBitmap->GetLastStatus() == Gdiplus::Ok)
		{
			if (m_hBitmap)
				::DeleteObject(m_hBitmap);
			pBitmap->GetHBITMAP(NULL, &m_hBitmap);
		}

		BITMAP bmpData;
		::GetObject(m_hBitmap, sizeof(BITMAP), &bmpData);
		m_iWidth = bmpData.bmWidth;
		m_iHeight = bmpData.bmHeight;
		m_bUseBitblt = bmpData.bmBitsPixel < 32;

		delete pBitmap;

		return true;
	}
	return false;
}
开发者ID:Williamzuckerberg,项目名称:chtmoneyhub,代码行数:30,代码来源:TuoImage.cpp

示例5: CreateImageList

/**
 * Creates an image list.
 * @param id Bitmap resource id.
 * @remark This method assumes that id+1 is the 32-bit toolbar image. Further images
 * can be added to support different color depths.
 * @return A handle to the imagelist or NULL on failure.
 */
HIMAGELIST ToolbarControl::CreateImageList( Int id ) {
    HIMAGELIST imageList = NULL;

    OSVERSIONINFO ovi;
    ovi.dwOSVersionInfoSize = sizeof(ovi);
    ::GetVersionEx( &ovi );

    if( ovi.dwMajorVersion >= 5 && ovi.dwMinorVersion >= 1 ) {
        // Windows XP or above
        Gdiplus::Bitmap* bitmap = ResourceManager::LoadImage( MAKEINTRESOURCE(id), "PNG" );
        if( bitmap != NULL ) {
            HBITMAP hBitmap;
            bitmap->GetHBITMAP(Gdiplus::Color(0xFFFFFFFF), &hBitmap);
            
            imageList = ImageList_Create( imageWidth, imageHeight, ILC_COLOR32, 6, 1 );
            ImageList_Add( imageList, hBitmap, NULL );

            ::DeleteObject( hBitmap );
            delete bitmap;
        }
    }
    else {
        HBITMAP hBitmap = (HBITMAP)::LoadImageA( g_hInstance, MAKEINTRESOURCE( id ), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );

        imageList = ImageList_Create( imageWidth, imageHeight, ILC_MASK | ILC_COLOR24, 6, 1 );
        ImageList_AddMasked( imageList, hBitmap, RGB(255, 0, 255) );

        ::DeleteObject( hBitmap );
    }

    IMAGEINFO ii;
    ImageList_GetImageInfo( imageList, 0, &ii );

    return imageList;
}
开发者ID:GDXN,项目名称:fitsliberator,代码行数:42,代码来源:ToolbarControl.cpp

示例6: convertToJPEG

///Convert the given RGB array to a JPEG image. The JPEG image is returned in a BYTE array while the length of the array is returned through parameter
BYTE* convertToJPEG(BYTE* RGBArray, UINT &length) {
    BITMAPINFO bmi;											//Create bitmap header
    memset(&bmi, 0, sizeof(bmi));
    bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth = 1920;
    bmi.bmiHeader.biHeight = -1080;
    bmi.bmiHeader.biPlanes = 1;
    bmi.bmiHeader.biCompression = BI_RGB;
    bmi.bmiHeader.biBitCount = 24;

    Gdiplus::Bitmap* myImage = new Gdiplus::Bitmap(&bmi, RGBArray);		//Form bitmap out of provided RGB array
    IStream *jpgStream;
    CLSID jpgClsid;
    GetEncoderClsid(L"image/jpeg", &jpgClsid);				//Get the encoder
    CreateStreamOnHGlobal(NULL, TRUE, &jpgStream);			//Get direct access to physical memory. Create a stream to save directly into it. Delete when stream is released
    myImage->Save(jpgStream, &jpgClsid);					//Save the jpg image into physical memory
    STATSTG stats;
    jpgStream->Stat(&stats, STATFLAG_NONAME);				//Get stats of the jpg image; more importantly, the size
    BYTE *jpg = new BYTE[stats.cbSize.QuadPart];			//Create byte array for transferring image to.
    ULONG read;
    LARGE_INTEGER lg;
    lg.QuadPart = 0;
    jpgStream->Seek(lg, STREAM_SEEK_SET, NULL);				//Move to beginning of stream
    jpgStream->Read(jpg, stats.cbSize.QuadPart, &read);		//Read entire stream into the array
    jpgStream->Release();									//Release the stream
    length = stats.cbSize.QuadPart;							//Save the length of the byte array
    return jpg;

}
开发者ID:si2dharth,项目名称:KinectServer,代码行数:30,代码来源:KinectThread.cpp

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

示例8: sizeof

Gdiplus::Bitmap* GdiplusUtilities::FromHICON32(HICON hIcon)
{
	Gdiplus::Bitmap* ret = NULL;
	ICONINFO iconInfo;
	GetIconInfo(hIcon, &iconInfo);
	BITMAP bitmapData;
	GetObject(iconInfo.hbmColor, sizeof(BITMAP), &bitmapData);

	if (bitmapData.bmBitsPixel != 32)
		ret = Gdiplus::Bitmap::FromHICON(hIcon);
	else
	{
		ret = new Gdiplus::Bitmap(bitmapData.bmWidth, bitmapData.bmHeight, PixelFormat32bppARGB);
		Gdiplus::BitmapData bmpData;
		ret->LockBits(&Gdiplus::Rect(0,0,bitmapData.bmWidth, bitmapData.bmHeight), Gdiplus::ImageLockModeWrite, PixelFormat32bppARGB, &bmpData);
#ifndef GetDIBitsVERSION
		//===Version GetBitmapBits
		// THIS FUNCTION IS UNDER TESTING. WHAT IF THE bitmap stride is different? Where will the new data go?
		ASSERT(bmpData.Stride == bmpData.Width * 4);
		::GetBitmapBits(iconInfo.hbmColor, 4 * bitmapData.bmWidth * bitmapData.bmHeight, bmpData.Scan0);
		//===Version GetBitmapBits===END
#else
		//===Version GetDIBits (incomplete)
		::GetDIBits(GetDC(), iconInfo.hbmColor, 0, bitmapData.bm)
			//===Version GetDIBits
#endif
			ret->UnlockBits(&bmpData);
	} 
	DeleteObject(iconInfo.hbmColor);
	DeleteObject(iconInfo.hbmMask);
	return ret;
}
开发者ID:KurzedMetal,项目名称:Jaangle,代码行数:32,代码来源:GdiplusUtilities.cpp

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

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

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

示例12: Export

void TVizMapContext::Export(const TStr& FNm, const TStr& EncoderType, const int& Width, 
        const int& Height, const bool& ShowPointNmP, const int& PointFontSize, 
        const int& PointNmFontScale, const double& PointWgtThreshold, const bool& ShowCatNmP,
        const bool& ShowKeyWdP, const int& KeyWdFontSize, const bool& ShowMgGlassP, 
        const int& LegendGridWidth, const int& LegendGridHeight) {

    // create graphics
    Gdiplus::Bitmap* Bmp = new Gdiplus::Bitmap(Width, Height);
    Gdiplus::Graphics* g = Gdiplus::Graphics::FromImage(Bmp);
    PGks BmpGks = TWfGks::New();
    // paint graphics
    HDC HdcHandle = g->GetHDC(); BmpGks->BeginPaint(HdcHandle);
    Paint(BmpGks, ShowPointNmP, PointFontSize, PointNmFontScale,
        PointWgtThreshold, -1, ShowCatNmP, ShowKeyWdP, KeyWdFontSize, ShowMgGlassP, 
        LegendGridWidth, LegendGridHeight);
    BmpGks->EndPaint(); g->ReleaseHDC(HdcHandle);
    // save to disk
    WCHAR* FNmWChar = new WCHAR[FNm.Len() + 1];
    const int Res = MultiByteToWideChar(CP_ACP, 0, 
        FNm.CStr(), FNm.Len() + 1, FNmWChar, FNm.Len() + 1);
    CLSID pngClsid; GetEncoderClsid(EncoderType, &pngClsid);
    Bmp->Save(FNmWChar, &pngClsid, NULL);
    // clean after
    delete FNmWChar; delete Bmp; delete g;
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:25,代码来源:vizmapgks.cpp

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

示例14:

// description: load image from file using gdi+
NaImage * NaImage::Load(const wchar_t * filename)
{
	NaImage *pImage = new NaImage;
	HDC hDC = NaScreenModule::GetDesktopDC();
	pImage->m_hMemoryDC = ::CreateCompatibleDC(hDC);

	// initialize gdi+
	Gdiplus::GdiplusStartupInput gdiplusStartupInput;
	ULONG_PTR gdiplusToken;
	GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

	// load image
	Gdiplus::Image* pGdiImage = new Gdiplus::Image(filename);

	// converting to bitmap
	Gdiplus::Bitmap* pGdiBitmap = static_cast<Gdiplus::Bitmap*>(pGdiImage);
	pGdiBitmap->GetHBITMAP(Gdiplus::Color(0, 0, 0), &pImage->m_hBitmap);

	pImage->m_rc.left = 0;
	pImage->m_rc.top = 0;
	pImage->m_rc.right = pGdiImage->GetWidth();
	pImage->m_rc.bottom = pGdiImage->GetHeight();

	// shutdown gdi+
	delete pGdiImage;
	Gdiplus::GdiplusShutdown(gdiplusToken);

	return pImage;
}
开发者ID:neoarc,项目名称:NaMacroJS,代码行数:30,代码来源:NaImage.cpp

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


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