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


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

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


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

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

示例2: MAKEINTRESOURCE

CResourceBitmap::CResourceBitmap(int resId) :
	m_hGlobal(NULL)
{
	HRSRC hRes = ::FindResource(g_hInstance, MAKEINTRESOURCE(resId), L"PNG");

	if(!hRes)
	{
		return;
	}

	DWORD dwSize = ::SizeofResource(g_hInstance, hRes);
	const void *pResData = ::LockResource(
		::LoadResource(g_hInstance, hRes));

	if(dwSize < 1 || !pResData)
	{
		return;
	}

	HGLOBAL hGlob = ::GlobalAlloc(GMEM_MOVEABLE, dwSize);

	if(hGlob)
	{
		void *pGlobBuf = ::GlobalLock(hGlob);

		if(pGlobBuf)
		{
			memcpy_s(pGlobBuf, dwSize, pResData, dwSize);

			IStream *pStream;
			if(SUCCEEDED(::CreateStreamOnHGlobal(hGlob, FALSE, &pStream)))
			{
				Gdiplus::Bitmap* gdipBmp = Gdiplus::Bitmap::FromStream(pStream);

				// done its duty here, Bitmap probably keeps a ref:
				pStream->Release();

				if(gdipBmp && gdipBmp->GetLastStatus() == Gdiplus::Ok)
				{
					// it worked!
					m_hGlobal = hGlob;
					m_bmp = std::shared_ptr<Gdiplus::Bitmap>(gdipBmp);

					return; // postpone cleanup to destructor! ;)
				}

				delete gdipBmp;
			}

			::GlobalUnlock(pGlobBuf);
		}

		::GlobalFree(hGlob);
	}
}
开发者ID:BGCX261,项目名称:znc-msvc-svn-to-git,代码行数:55,代码来源:resource_bitmap.cpp

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

示例4: OnInitDialog

BOOL CVideoPane::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here

	// 获取参数
	CRect rect;
	GetClientRect(rect);
	CString strOcxPath = eLTE_Tool::GetOcxPath();

	// 设置图标
	Gdiplus::Bitmap* pBitmap = Gdiplus::Bitmap::FromFile(strOcxPath + _T("Skin\\Icon.ico"));
	if (NULL != pBitmap && Gdiplus::Ok == pBitmap->GetLastStatus())
	{
		HICON hIcon = NULL;
		pBitmap->GetHICON(&hIcon);
		if (NULL != hIcon)
		{
			SetIcon(hIcon, FALSE);		// Set small icon
			SetIcon(hIcon, TRUE);		// Set big icon
		}
	}

	// 显示边框
	ModifyStyle(0, WS_BORDER);
	SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_DRAWFRAME);

	// 创建标题栏
	CreateCaption(rect, strOcxPath);

	// 创建视频窗口
	CreateVideoStatic(rect, strOcxPath);

	// 创建工具栏
	CreateToolBar(rect, strOcxPath);

	// 禁用按钮
	EnableImageButton(FALSE);

	// 工具栏隐藏
	if (!m_bShowToolBar)
	{
		m_SnapshotBtn.ShowWindow(SW_HIDE);
		m_ReversePlayBtn.ShowWindow(SW_HIDE);
		m_FullScreenBtn.ShowWindow(SW_HIDE);
		m_AudioBtn.ShowWindow(SW_HIDE);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
开发者ID:eSDK,项目名称:esdk_elte,代码行数:52,代码来源:VideoPane.cpp

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

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

示例7: LoadFromMemory

int SSkinGif::LoadFromMemory( LPVOID pBuf,size_t dwSize )
{
    HGLOBAL hMem = ::GlobalAlloc(GMEM_FIXED, dwSize);
    BYTE* pMem = (BYTE*)::GlobalLock(hMem);

    memcpy(pMem, pBuf, dwSize);

    IStream* pStm = NULL;
    ::CreateStreamOnHGlobal(hMem, TRUE, &pStm);
    Gdiplus::Bitmap *pImg = Gdiplus::Bitmap::FromStream(pStm);
    if(!pImg || pImg->GetLastStatus() != Gdiplus::Ok)
    {
        pStm->Release();
        ::GlobalUnlock(hMem);
        return 0;
    }

    LoadFromGdipImage(pImg);
    delete pImg;
    return m_nFrames;
}
开发者ID:3rdexp,项目名称:soui,代码行数:21,代码来源:SSkinGif.cpp

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

示例9: SetUUIDOverlayIcon

void SetUUIDOverlayIcon( HWND hWnd )
{
    if (!CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepo"), 3))
        return;

    if (!CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepoOverlay"), TRUE))
        return;

    std::wstring uuid;
    std::wstring sicon;
    bool bRemoveicon = false;
#ifdef __AFXWIN_H__
    uuid = g_sGroupingUUID;
    sicon = g_sGroupingIcon;
    bRemoveicon = g_bGroupingRemoveIcon;
#else
    CCmdLineParser parser(GetCommandLine());
    if (parser.HasVal(L"groupuuid"))
        uuid = parser.GetVal(L"groupuuid");
#endif
    if (uuid.empty())
        return;

    CComPtr<ITaskbarList3> pTaskbarInterface;
    if (FAILED(pTaskbarInterface.CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_INPROC_SERVER)))
        return;

    int foundUUIDIndex = 0;
    do
    {
        wchar_t buf[MAX_PATH] = { 0 };
        swprintf_s(buf, _countof(buf), L"%s%d", L"Software\\TortoiseGit\\LastUsedUUIDsForGrouping\\", foundUUIDIndex);
        CRegStdString r = CRegStdString(buf);
        std::wstring sr = r;
        if (sr.empty())
        {
            r = uuid + (sicon.empty() ? L"" : (L";" + sicon));
            break;
        }
        size_t sep = sr.find(L';');
        std::wstring olduuid = sep != std::wstring::npos ? sr.substr(0, sep) : sr;
        if (olduuid.compare(uuid) == 0)
        {
            if (bRemoveicon)
                r = uuid; // reset icon path in registry
            else if (!sicon.empty())
                r = uuid + (sicon.empty() ? L"" : (L";" + sicon));
            else
                sicon = sep != std::wstring::npos ? sr.substr(sep + 1) : L"";
            break;
        }
        foundUUIDIndex++;
    } while (foundUUIDIndex < 20);
    if (foundUUIDIndex >= 20)
    {
        CRegStdString r = CRegStdString(L"Software\\TortoiseGit\\LastUsedUUIDsForGrouping\\1");
        r.removeKey();
    }

    HICON icon = nullptr;
    if (!sicon.empty())
    {
        if (sicon.size() >= 4 && !_wcsicmp(sicon.substr(sicon.size() - 4).c_str(), L".ico"))
            icon = (HICON)::LoadImage(nullptr, sicon.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE | LR_SHARED);
        else
        {
            ULONG_PTR gdiplusToken = 0;
            Gdiplus::GdiplusStartupInput gdiplusStartupInput;
            GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);
            if (gdiplusToken)
            {
                Gdiplus::Bitmap* pBitmap = new Gdiplus::Bitmap(sicon.c_str(), FALSE);
                if (pBitmap->GetLastStatus() == Gdiplus::Status::Ok)
                    pBitmap->GetHICON(&icon);
                delete pBitmap;
                Gdiplus::GdiplusShutdown(gdiplusToken);
            }
        }
    }

    if (!icon)
    {
        DWORD colors[6] = { 0x80FF0000, 0x80FFFF00, 0x8000FF00, 0x800000FF, 0x80000000, 0x8000FFFF };

        // AND mask - monochrome - determines which pixels get drawn
        BYTE AND[32];
        for (int i = 0; i<32; i++)
        {
            AND[i] = 0xFF;
        }

        // XOR mask - 32bpp ARGB - determines the pixel values
        DWORD XOR[256];
        for (int i = 0; i<256; i++)
        {
            XOR[i] = colors[foundUUIDIndex % 6];
        }

        icon = ::CreateIcon(nullptr, 16, 16, 1, 32, AND, (BYTE*)XOR);
    }
//.........这里部分代码省略.........
开发者ID:AJH16,项目名称:TortoiseGit,代码行数:101,代码来源:TaskbarUUID.cpp

示例10: LoadTexture

//*************************************************************************************************************
GLuint LoadTexture(const std::wstring& file)
{
	GLuint texid = 0;
	Gdiplus::Bitmap* bitmap = LoadPicture(file);

	if( bitmap )
	{ 
		if( bitmap->GetLastStatus() == Gdiplus::Ok )
		{
			Gdiplus::BitmapData data;
			unsigned char* tmpbuff;

			bitmap->LockBits(0, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &data);

			tmpbuff = new unsigned char[data.Width * data.Height * 4];
			memcpy(tmpbuff, data.Scan0, data.Width * data.Height * 4);

			for( UINT i = 0; i < data.Height; ++i )
			{
				// swap red and blue
				for( UINT j = 0; j < data.Width; ++j )
				{
					UINT index = (i * data.Width + j) * 4;
					std::swap<unsigned char>(tmpbuff[index + 0], tmpbuff[index + 2]);
				}

				// flip on X
				for( UINT j = 0; j < data.Width / 2; ++j )
				{
					UINT index1 = (i * data.Width + j) * 4;
					UINT index2 = (i * data.Width + (data.Width - j - 1)) * 4;

					std::swap<unsigned int>(*((unsigned int*)(tmpbuff + index1)), *((unsigned int*)(tmpbuff + index2)));
				}
			}

			glGenTextures(1, &texid);
			glBindTexture(GL_TEXTURE_2D, texid);

			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

			glBindTexture(GL_TEXTURE_2D, texid);
			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, data.Width, data.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmpbuff);
			glBindTexture(GL_TEXTURE_2D, 0);

			GLenum err = glGetError();

			if( err != GL_NO_ERROR )
				MYERROR("Could not create texture")
			else
				std::cout << "Created texture " << data.Width << "x" << data.Height << "\n";

			bitmap->UnlockBits(&data);
			delete[] tmpbuff;
		}

		delete bitmap;
	}
开发者ID:galek,项目名称:Asylum_Tutorials,代码行数:63,代码来源:other.cpp


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