Пример #1
0
// 读取图片(从文件读)
BOOL LoadBitmapFromFile(const CString strPathFile, CBitmap &bitmap, CSize &size)
{	
	HBITMAP hBitmap = NULL;
#ifdef _UNICODE
	Bitmap* pBitmap = Bitmap::FromFile(strPathFile);
#else
	Bitmap* pBitmap = Bitmap::FromFile(CEncodingUtil::AnsiToUnicode(strPathFile));
#endif
	Status status = pBitmap->GetLastStatus();
	if(Ok == status)
	{		
		status = pBitmap->GetHBITMAP(Color(0,0,0), &hBitmap);
		if(Ok == status)
		{
			if(bitmap.m_hObject != NULL)
			{
				bitmap.Detach();
			}
			bitmap.Attach(hBitmap);
			
			BITMAP bmInfo;
			::GetObject( bitmap.m_hObject, sizeof(BITMAP), &bmInfo );
			size.cx = bmInfo.bmWidth;
			size.cy = bmInfo.bmHeight;

			delete pBitmap;

			return TRUE;
		}
	}

	return FALSE;
}
Пример #2
0
RenderedBitmap *LoadRenderedBitmap(const WCHAR *filePath)
{
    if (str::EndsWithI(filePath, L".bmp")) {
        HBITMAP hbmp = (HBITMAP)LoadImage(NULL, filePath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
        if (!hbmp)
            return NULL;
        return new RenderedBitmap(hbmp, GetBitmapSize(hbmp));
    }

    size_t len;
    ScopedMem<char> data(file::ReadAll(filePath, &len));
    if (!data)
        return NULL;
    Bitmap *bmp = BitmapFromData(data, len);
    if (!bmp)
        return NULL;

    HBITMAP hbmp;
    RenderedBitmap *rendered = NULL;
    if (bmp->GetHBITMAP(Color::White, &hbmp) == Ok)
        rendered = new RenderedBitmap(hbmp, SizeI(bmp->GetWidth(), bmp->GetHeight()));
    delete bmp;

    return rendered;
}
int CShoshTreeCtrl::AddImageList(const char* stfilePath)
{
	bool bRet=  m_xImage->Load(stfilePath,CXIMAGE_FORMAT_PNG);
	CDC *pDC = GetDC();

	Bitmap * pbmp = GetNewBitmap(stfilePath);
	if (pbmp == NULL) return -1;
	m_pBitMapList2.push_back(pbmp);

	Color cr = Color::White;


	HBITMAP hBitmap = NULL ;//m_xImage->MakeBitmap(pDC->GetSafeHdc());
	pbmp->GetHBITMAP( cr, &hBitmap );

	if ( NULL != hBitmap )  
	{  

		CBitmap* pBitmap;

		pBitmap = new CBitmap;
		m_pBitMapList.push_back(pBitmap);
		pBitmap->Attach(hBitmap);   

		int nRetNum = m_ImageList.Add(pBitmap,RGB(0,0,0));
		return nRetNum;
	}
	return -1;
}
 virtual RenderedBitmap *GetImage() {
     HBITMAP hbmp;
     Bitmap *bmp = BitmapFromData(id->data, id->len);
     if (!bmp || bmp->GetHBITMAP(Color::White, &hbmp) != Ok) {
         delete bmp;
         return NULL;
     }
     SizeI size(bmp->GetWidth(), bmp->GetHeight());
     delete bmp;
     return new RenderedBitmap(hbmp, size);
 }
Пример #5
0
HBITMAP loadImageFromBuffer(const void* buf, unsigned int size, HWND hWnd, const BOOL& keepAspect, const BOOL& resize)
{
	if (!buf) {
		return NULL;
	}

	if (!bUseGdip) {
		return loadPNGFromBuffer(buf, size, hWnd, keepAspect, resize);
	}

	HGLOBAL hBuffer = ::GlobalAlloc(GMEM_MOVEABLE, size);
	if (!hBuffer) {
		return NULL;
	}

	Bitmap* pBitmap = NULL;
	Status stat;

	void* pBuffer = ::GlobalLock(hBuffer);
	if (pBuffer)
	{
		memcpy(pBuffer, buf, size);

		IStream* pStream = NULL;
		if (::CreateStreamOnHGlobal(hBuffer, FALSE, &pStream) == S_OK) {
			// create a new Image object based on pStream
			pBitmap = Bitmap::FromStream(pStream);
			stat = pBitmap->GetLastStatus();
			pStream->Release();
		}
		::GlobalUnlock(hBuffer);
	}
	::GlobalFree(hBuffer);

	if (stat != Ok) {
		if (pBitmap) {
			delete pBitmap;
		}
		return NULL;
	}

	HBITMAP hBitmap = NULL;
	pBitmap->GetHBITMAP(color, &hBitmap);

	if (resize) {
		hBitmap = resizeBitmap(hWnd, hBitmap, pBitmap->GetWidth(), pBitmap->GetHeight(), keepAspect);
	}

	if (pBitmap) {
		delete pBitmap;
	}

	return hBitmap;
}
Пример #6
0
// 读取图片(从资源读)
BOOL LoadBitmapFromIDResource(UINT nID, CBitmap &bitmap, CSize &size, CString strType)
{
	HINSTANCE hInst = AfxGetResourceHandle();  
	HRSRC hRsrc = ::FindResource (hInst,MAKEINTRESOURCE(nID), strType);
	if (!hRsrc)  
	{
		return FALSE; 
	}

	DWORD len = SizeofResource(hInst, hRsrc);  
	BYTE* lpRsrc = (BYTE*)LoadResource(hInst, hRsrc);  
	if (!lpRsrc)  
	{
		return FALSE;
	}
	HGLOBAL m_hMem = GlobalAlloc(GMEM_FIXED, len);  
	BYTE* pmem = (BYTE*)GlobalLock(m_hMem);  
	memcpy(pmem,lpRsrc,len);  
	IStream* pstm;  
	CreateStreamOnHGlobal(m_hMem,FALSE,&pstm);  
	Bitmap* pBitmap = Gdiplus::Bitmap::FromStream(pstm);  
	GlobalUnlock(m_hMem);  
	GlobalFree(m_hMem);
	pstm->Release();  
	FreeResource(lpRsrc); 

	HBITMAP hBitmap = NULL;
	Status status = pBitmap->GetLastStatus();
	if(Ok == status)
	{		
		status = pBitmap->GetHBITMAP(Color(0,0,0), &hBitmap);
		delete pBitmap;

		if(Ok == status)
		{
			if(bitmap.m_hObject != NULL)
			{
				bitmap.Detach();
			}
			bitmap.Attach(hBitmap);

			BITMAP bmInfo;
			::GetObject( bitmap.m_hObject, sizeof(BITMAP), &bmInfo );
			size.cx = bmInfo.bmWidth;
			size.cy = bmInfo.bmHeight;				

			return TRUE;
		}
	}

	return FALSE;
}
Пример #7
0
HBITMAP GDIPlus_LoadGlyphImage(const wchar_t *tszFileName)
{
	// Create a Bitmap object from a JPEG file.
	Bitmap bitmap(tszFileName, 0);

	// Clone a portion of the bitmap.
	Bitmap* clone = bitmap.Clone(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), PixelFormat32bppPARGB);
	HBITMAP hbmp = nullptr;
	if (clone) {
		clone->GetHBITMAP(Color(0, 0, 0), &hbmp);
		delete clone;
	}
	return hbmp;
}
Пример #8
0
LIBELCBASEUI_API BOOL LoadImageFromBuffer(LPBYTE lpBuffer, int cbBuffer, CBitmap* pBitmap, CSize& size)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	if (!lpBuffer || cbBuffer <= 0 || !pBitmap)
		return FALSE;

	IStream* pstm = NULL;
	Bitmap *pImage = NULL;
	BOOL bSuccessful = FALSE;
	PBYTE pMem = NULL;
	HGLOBAL hMem = NULL;
	
	do 
	{
		hMem = GlobalAlloc(GMEM_FIXED, cbBuffer);
		pMem = (BYTE*)GlobalLock(hMem);
		memcpy(pMem, lpBuffer, cbBuffer);
		CreateStreamOnHGlobal(hMem, FALSE, &pstm);

		pImage = Bitmap::FromStream(pstm);
		if (!pImage || pImage->GetLastStatus() != Ok)
			break;

		HBITMAP hBitmap = NULL;
		pImage->GetHBITMAP(Color::White, &hBitmap);
		pBitmap->DeleteObject();
		if (!pBitmap->Attach(hBitmap))
			break;

		BITMAP bm;
		GetObject(pBitmap->m_hObject, sizeof(bm), &bm);

		size.cx = pImage->GetWidth();
		size.cy = pImage->GetHeight();

		bSuccessful = TRUE;
	} while (0);

	if (hMem)
		GlobalUnlock(hMem);
	if (pstm)
		pstm->Release();
	if (pImage)
		delete pImage;

	return bSuccessful;
}
Пример #9
0
void CCxLoginBar::OnLoadImages ()
{
	//static const int cxImg = 16;
	//static const int cyImg = 16;

	static const LPCTSTR arrImageName[] = {
		"User.png",
		"Login.png", "login_Pressed.png", "login_Focused.png",
		"Logout.png", "logout_Pressed.png", "logout_Focused.png"
	};

	CString strDir = GetExecDir() + "\\Res\\Login\\";
	Bitmap * pBitmap = NULL;
	HBITMAP hbmp = NULL;

	//ResetAll();
	ClearImages();

	Color crImgBg;
	crImgBg.SetFromCOLORREF(g_crToolbarBg);

	//m_BCGToolbarImages.SetImageSize( CSize(cxImg, cyImg) );
	m_BCGToolbarImages.SetTransparentColor (g_crToolbarBg);

	int nCount = sizeof( arrImageName ) / sizeof( LPCTSTR );
	for (int i=0; i<nCount; i++)
	{
		pBitmap = GetNewBitmap( strDir + arrImageName[i] );
		if ( pBitmap == NULL )
		{
			ClearImages();
			return;
		}
		m_vImages.push_back( pBitmap );
		pBitmap->GetHBITMAP( crImgBg, &hbmp);
		if ( hbmp == NULL )
		{
			ClearImages();
			return;
		}
		m_vHBitmaps.push_back( hbmp );
		m_BCGToolbarImages.AddImage( hbmp );
	}

	if ( m_BCGToolbarImages.GetCount() == 0 ) return;
}
static RenderedBitmap *LoadRenderedBitmap(const WCHAR *filePath)
{
    size_t len;
    ScopedMem<char> data(file::ReadAll(filePath, &len));
    if (!data)
        return NULL;
    Bitmap *bmp = BitmapFromData(data, len);
    if (!bmp)
        return NULL;

    HBITMAP hbmp;
    RenderedBitmap *rendered = NULL;
    if (bmp->GetHBITMAP((ARGB)Color::White, &hbmp) == Ok)
        rendered = new RenderedBitmap(hbmp, SizeI(bmp->GetWidth(), bmp->GetHeight()));
    delete bmp;

    return rendered;
}
Пример #11
0
void CBalloonTip::InitIconImage()
{
	HICON hIcon = LoadIcon(CPaintManagerUI::GetResourceDll(),MAKEINTRESOURCE(m_nIcon));
	if (hIcon)
	{
		ICONINFO icInfo = { 0 };
		if (::GetIconInfo(hIcon, &icInfo))
		{
			BITMAP bitmap; 
			GetObject(icInfo.hbmColor, sizeof(BITMAP), &bitmap);

			Bitmap* pBitmap = NULL;
			Bitmap* pWrapBitmap = NULL;
			if (bitmap.bmBitsPixel != 32)
			{   
				pBitmap = Bitmap::FromHICON(hIcon);
			} 
			else
			{
				pWrapBitmap = Bitmap::FromHBITMAP(icInfo.hbmColor, NULL);
				BitmapData bitmapData;
				Rect rcImage(0,0, pWrapBitmap->GetWidth(), pWrapBitmap->GetHeight());
				pWrapBitmap->LockBits(&rcImage, ImageLockModeRead, pWrapBitmap->GetPixelFormat(), &bitmapData); 

				pBitmap = new Bitmap(bitmapData.Width, bitmapData.Height, bitmapData.Stride,  PixelFormat32bppARGB, (BYTE*)bitmapData.Scan0);

				pWrapBitmap->UnlockBits(&bitmapData);
			}

			//lpIconImage = pBitmap->Clone(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight(), PixelFormat32bppARGB);

			HBITMAP hBit ;

			pBitmap->GetHBITMAP(ARGB(0,0,0,0),&hBit);

			m_pPM->AddImage(_T("BalloonIcon"),hBit,pBitmap->GetWidth(),pBitmap->GetHeight(),TRUE);

			DeleteObject(icInfo.hbmColor); 
			DeleteObject(icInfo.hbmMask); 
		}
		DeleteObject(hIcon);
	}
}
Пример #12
0
static RenderedBitmap* LoadRenderedBitmap(const WCHAR* filePath) {
    OwnedData data(file::ReadFile(filePath));
    if (!data.data) {
        return nullptr;
    }
    Bitmap* bmp = BitmapFromData(data.data, data.size);
    if (!bmp) {
        return nullptr;
    }

    HBITMAP hbmp;
    RenderedBitmap* rendered = nullptr;
    if (bmp->GetHBITMAP((ARGB)Color::White, &hbmp) == Ok) {
        rendered = new RenderedBitmap(hbmp, SizeI(bmp->GetWidth(), bmp->GetHeight()));
    }
    delete bmp;

    return rendered;
}
Пример #13
0
Bool AlphaWindow::ApplyBitmap( Bitmap& bitmap ) {
    Bool success = false;

    SizeF bitmapSize;
    bitmap.GetPhysicalDimension( &bitmapSize );

    // Size and move our window
    FitsLiberator::Rectangle windowBounds( 0, 0, (Int)bitmapSize.Width, (Int)bitmapSize.Height );
    setBounds( windowBounds );
    Center();
    windowBounds = getBounds();

    HDC screenDC = ::GetDC( NULL );
    HDC memDC    = ::CreateCompatibleDC( screenDC );
    HBITMAP hBitmap = NULL;
    HBITMAP hOldBitmap = NULL;

    if( Ok == bitmap.GetHBITMAP( Gdiplus::Color(0), &hBitmap ) ) {
        hOldBitmap = (HBITMAP)::SelectObject( memDC, hBitmap );
        
        SIZE newSize = { (Int)bitmapSize.Width, (Int)bitmapSize.Height };
        POINT sourceLocation = { 0, 0 };
        POINT newLocation = { windowBounds.left, windowBounds.top };
        BLENDFUNCTION blend;
        blend.BlendOp = AC_SRC_OVER;
        blend.BlendFlags = 0;
        blend.SourceConstantAlpha = 255;
        blend.AlphaFormat = AC_SRC_ALPHA;

        ::UpdateLayeredWindow( hWnd, screenDC, &newLocation, &newSize, memDC, &sourceLocation, 0, &blend, ULW_ALPHA );
        success = true;
    }

    ::ReleaseDC( NULL, screenDC );
    if( hBitmap != NULL ) {
        ::SelectObject( memDC, hOldBitmap );
        ::DeleteObject( hBitmap );
    }
    ::DeleteDC( memDC );

    return success;
}
Пример #14
0
 virtual RenderedBitmap *GetImage() {
     HBITMAP hbmp;
     if (bmp->GetHBITMAP(Color::White, &hbmp) != Ok)
         return NULL;
     return new RenderedBitmap(hbmp, SizeI(bmp->GetWidth(), bmp->GetHeight()));
 }
Пример #15
0
HRESULT CProteinVistaApp::MakeMovieWithImages(CString movieFilename, CStringArray & strArrayFilename, CSTLIntArray & arrayFrame, 
										int width, int height, int fps )
{
	HRESULT hr;
	USES_CONVERSION;

	if ( strArrayFilename.GetSize() == 0 )
		return E_FAIL;

	int	bitmapWidth = width;
	int	bitmapHeight = height;

	if ( bitmapWidth == -1 || bitmapHeight == -1 )
	{
		Bitmap * bitmap = Bitmap::FromFile(A2W(strArrayFilename[0]));
		if ( bitmap == NULL )
		{
			return E_FAIL;
		}		

		bitmapWidth = bitmap->GetWidth();
		bitmapHeight = bitmap->GetHeight();

		delete bitmap;
	}

	IWMProfile *pProfile=NULL;
	{
		IWMProfileManager *pProfileManager=NULL;

		if(FAILED(WMCreateProfileManager(&pProfileManager)))
		{
			AfxMessageBox(_T("Unable to Create WindowsMedia Profile Manager"));
			return E_FAIL;
		}

		CString profileFilename;
		profileFilename.Format("%sHD_Recording.xml" , ((CProteinVistaApp *)AfxGetApp())->m_strBaseResPath );

		// Reading buffer
		CFile* pFile = new CFile(profileFilename, CFile::modeRead );
		if ( pFile->m_hFile != CFile::hFileNull )
		{
			long fileLen = pFile->GetLength()*sizeof(wchar_t) * 2;
			wchar_t * buffer = new wchar_t [fileLen];
			wchar_t * bufferProfile = new wchar_t [fileLen];
			ZeroMemory(buffer, fileLen);
			ZeroMemory(bufferProfile, fileLen);

			long nRead = pFile->Read( buffer, fileLen );
			pFile->Close();

			swprintf(bufferProfile, buffer, bitmapWidth, bitmapHeight, 
											bitmapWidth, bitmapHeight, 
											bitmapWidth, bitmapHeight );

			if(FAILED(pProfileManager->LoadProfileByData(bufferProfile, &pProfile)))
			{
				AfxMessageBox(_T("Unable to Load Data Profile"));
				return E_FAIL;
			}

			delete [] buffer;
			delete [] bufferProfile;

			SAFE_RELEASE(pProfileManager);
			SAFE_DELETE(pFile);
		}
		else
		{
			SAFE_RELEASE(pProfileManager);
			AfxMessageBox(_T("Cannot find HD_Recording.xml"));
			return E_FAIL;
		}
	}

	//
	//	movieFilename 을 지운다.
	TCHAR drive[MAX_PATH];
	TCHAR dir[MAX_PATH];
	TCHAR fname[MAX_PATH];
	TCHAR ext[MAX_PATH];
	_splitpath(movieFilename, drive, dir, fname, ext );

	CString strMovieFilename;
	if ( drive[0] != NULL && dir[0] != NULL )
	{
		strMovieFilename = CString(movieFilename);
	}
	else
	{
		strMovieFilename.Format(_T("%s%s%s") , ((CProteinVistaApp *)AfxGetApp())->m_strBaseScriptMovie, fname, ext );
	}

	DeleteFile(strMovieFilename);

	//
	CwmvFile	wmvFile (strMovieFilename, pProfile, fps);
	if ( wmvFile.GetLastErrorMessage() != CString (_T("Method Succeeded") ) )
	{
		CString strText;
		strText.Format( "%s: Cannot open %s", wmvFile.GetLastErrorMessage(), movieFilename );
		AfxMessageBox ( strText );
		
		return E_FAIL;
	}

	for ( int i = 0 ; i < strArrayFilename.GetSize(); i++ )
	{
		USES_CONVERSION;
		Bitmap * bitmap = Bitmap::FromFile(A2W(strArrayFilename[i]));

		Color colorBackground;
		HBITMAP hBitmap;
		bitmap->GetHBITMAP(colorBackground,&hBitmap);

		long frames = arrayFrame[i];
		for ( int j = 0 ; j < frames ; j++ )
		{
			hr = wmvFile.AppendNewFrame(hBitmap);
		}
		if ( FAILED(hr) )
		{
			CString strText;
			strText.Format( "Movie Making Error: %s, %s", wmvFile.GetLastErrorMessage(), strArrayFilename[i] );
			AfxMessageBox ( strText );
			
			delete bitmap;

			return E_FAIL;
		}
		delete bitmap;
	}

	return S_OK;
}
Пример #16
0
// 读取图片(从内存中加载)
BOOL LoadBitmapFromMem(BYTE* pByte, DWORD dwSize, CBitmap &bitmap, CSize &size)
{
	// 根据文件大小分配HGLOBAL内存
	HGLOBAL hGlobal = GlobalAlloc( GMEM_MOVEABLE | GMEM_NODISCARD, dwSize );
	if ( !hGlobal )
	{
		TRACE( _T( "Load (file): Error allocating memory\n" ) );
		return FALSE;
	};

	char *pData = reinterpret_cast<char*>(GlobalLock(hGlobal));
	if ( !pData )
	{
		TRACE( _T( "Load (file): Error locking memory\n" ) );
		GlobalFree( hGlobal );
		return FALSE;
	};

	// 将文件内容读到HGLOBAL内存中
	memcpy(pData, pByte, dwSize);
	GlobalUnlock( hGlobal );

	// 利用hGlobal内存中的数据创建stream
	IStream *pStream = NULL;
	if ( CreateStreamOnHGlobal( hGlobal, TRUE, &pStream ) != S_OK )
	{
		return FALSE;
	}

	Bitmap* pBitmap = Gdiplus::Bitmap::FromStream(pStream);

	// 要加上这一句,否则由GlobalAlloc得来的hGlobal内存没有被释放,导致内存泄露,由于
	// CreateStreamOnHGlobal第二个参数被设置为TRUE,所以调用pStream->Release()会自动
	// 将hGlobal内存(参见msdn对CreateStreamOnHGlobal的说明)
	pStream->Release();

	HBITMAP hBitmap = NULL;
	Status status = pBitmap->GetLastStatus();
	if(Ok == status)
	{		
		status = pBitmap->GetHBITMAP(Color(0,0,0), &hBitmap);
		delete pBitmap;

		if(Ok == status)
		{
			if(bitmap.m_hObject != NULL)
			{
				bitmap.Detach();
			}
			bitmap.Attach(hBitmap);

			BITMAP bmInfo;
			::GetObject( bitmap.m_hObject, sizeof(BITMAP), &bmInfo );
			size.cx = bmInfo.bmWidth;
			size.cy = bmInfo.bmHeight;				

			return TRUE;
		}
	}

	return FALSE;
}
Пример #17
0
HBITMAP renderer::GetThumbnail()
{
    //Calculate icon size
    int iconsize = height;

    if (m_Settings.AsIcon)
    {
        if (width < iconsize)
            iconsize = width;        
        iconsize = (m_Settings.IconSize * iconsize) / 100;
        iconsize -= 2;
    }

    //Calculate Alpha blend based on Transparency
    float fBlend = (100-m_Settings.BG_Transparency)/100.0;

    ColorMatrix BitmapMatrix =	{     
        1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
        0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
        0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
        0.0f, 0.0f, 0.0f, fBlend, 0.0f,
        0.0f, 0.0f, 0.0f, 0.0f, 1.0f
    };

    bool tempfail = fail;
    int iconposition = m_Settings.IconPosition;

    // Draw background if not valid
    if (!background)
    {      
        if (m_Settings.Shrinkframe)
        {
            if (iconposition == IP_LOWERLEFT)
            {
                iconposition = IP_UPPERLEFT;
            }
            else if (m_Settings.IconPosition == IP_LOWERRIGHT)
            {
                iconposition = IP_UPPERRIGHT;
            }
        }

        no_icon = false;                
        fail = false;
        background = new Bitmap(width, height, PixelFormat32bppPARGB);

        switch (tempfail ? m_Settings.Revertto : m_Settings.Thumbnailbackground)
        {
        case BG_TRANSPARENT:
            no_icon = true;
            break;

        case BG_ALBUMART:
            {
                // get album art
                if (!m_albumart.getAA(m_metadata.getFileName(), background, 
                    width, height, iconsize) &&
                    m_Settings.Revertto != BG_ALBUMART)
                {
                    // fallback
                    fail = true;
                    ClearBackground();                            
                    GetThumbnail();
                }
                else
                {
                    m_iconwidth = iconsize;
                    m_iconheight = iconsize;
                }
            }
            break;

        case BG_CUSTOM:
            if (!m_Settings.BGPath.empty())
            {
                if (custom_img == NULL)
                {
                    custom_img = new Bitmap(width, height, PixelFormat32bppPARGB);                       

                    Image img(m_Settings.BGPath.c_str(), true);

                    if (img.GetType() != 0)
                    {
                        Graphics gfx(custom_img);
                        gfx.SetInterpolationMode(InterpolationModeBicubic);
                        float img_width = img.GetWidth();
                        float img_height = img.GetHeight();

                        if (m_Settings.AsIcon)
                        {
                            float new_height = 0;
                            float new_width = 0;

                            if (img_width > img_height)
                            {
                                new_height = img_height / img_width * (float)iconsize;
                                new_height -= 2;
                                new_width = iconsize;
                            }
                            else
                            {
                                new_width = img_width / img_height * (float)iconsize;
                                new_width -= 2;
                                new_height = iconsize;
                            }

                            int iconleft = 0, icontop = 0;

                            switch (iconposition)
                            {
                            case IP_LOWERLEFT:
                                icontop = height - iconsize - 2;
                                break;
                            case IP_UPPERRIGHT:
                                iconleft = width - iconsize - 2;
                                break;
                            case IP_LOWERRIGHT:
                                iconleft = width - iconsize - 2;
                                icontop = height - iconsize - 2;
                                break;
                            }            

                            if (m_Settings.BG_Transparency == 0)
                            {
                                // Draw icon shadow
                                gfx.SetSmoothingMode(SmoothingModeAntiAlias);
                                gfx.FillRectangle(&SolidBrush(Color::MakeARGB(110, 0, 0, 0)),
                                    static_cast<REAL>(iconleft + 1), static_cast<REAL>(icontop + 1), 
                                    static_cast<REAL>(new_width + 1), static_cast<REAL>(new_height + 1));

                                // Draw icon
                                gfx.SetSmoothingMode(SmoothingModeNone);
                                gfx.DrawImage(&img,
                                    RectF(static_cast<REAL>(iconleft), static_cast<REAL>(icontop), 
                                    static_cast<REAL>(new_width), static_cast<REAL>(new_height)));
                            }
                            else
                            {
                                ImageAttributes ImgAttr;
                                ImgAttr.SetColorMatrix(&BitmapMatrix, 
                                    ColorMatrixFlagsDefault, 
                                    ColorAdjustTypeBitmap);

                                // Draw icon shadow
                                gfx.SetSmoothingMode(SmoothingModeAntiAlias);
                                gfx.FillRectangle(&SolidBrush(Color::MakeARGB(110 - m_Settings.BG_Transparency, 0, 0, 0)),
                                    static_cast<REAL>(iconleft + 1), static_cast<REAL>(icontop + 1), 
                                    static_cast<REAL>(new_width + 1), static_cast<REAL>(new_height + 1));

                                // Draw icon
                                gfx.SetSmoothingMode(SmoothingModeNone);
                                gfx.DrawImage(&img,
                                    RectF(static_cast<REAL>(iconleft), static_cast<REAL>(icontop), 
                                    static_cast<REAL>(new_width), static_cast<REAL>(new_height)),
                                    0, 0, img_width, img_height,
                                    UnitPixel, &ImgAttr);
                            }

                            m_iconwidth = new_width;
                            m_iconheight = new_height;
                        }
                        else
                        {
                            float new_height = 0;
                            float new_width = 0;

                            if (width > height)
                            {
                                new_height = img_height / img_width * (float)width;                            
                                new_width = width;

                                if (new_height > height)
                                {
                                    new_width = img_width / img_height * (float)height;                         
                                    new_height = height;
                                }

                            }
                            else
                            {
                                new_width = img_width / img_height * (float)height;                         
                                new_height = height;

                                if (new_width > width)
                                {
                                    new_height = img_height / img_width * (float)width;                            
                                    new_width = width;
                                }
                            }

                            gfx.SetSmoothingMode(SmoothingModeNone);

                            if (m_Settings.BG_Transparency == 0)
                            {
                                gfx.DrawImage(&img, RectF((width / 2) - (new_width/2), 0, 
                                    static_cast<REAL>(new_width), static_cast<REAL>(new_height)));
                            }
                            else
                            {
                                ImageAttributes ImgAttr;
                                ImgAttr.SetColorMatrix(&BitmapMatrix, 
                                    ColorMatrixFlagsDefault, 
                                    ColorAdjustTypeBitmap);

                                gfx.SetSmoothingMode(SmoothingModeNone);
                                gfx.DrawImage(&img, RectF((width / 2) - (new_width/2), 0, static_cast<REAL>(new_width), static_cast<REAL>(new_height)),
                                    0, 0, img_width, img_height,
                                    UnitPixel, &ImgAttr);
                            }
                        }
                    }
                    else if (m_Settings.Revertto != BG_CUSTOM)
                    {
                        fail = true;
                        ClearBackground();
                        GetThumbnail();
                    }	                   
                }       

                delete background;
                background = (Bitmap*)custom_img->Clone();                
            }
            else if (m_Settings.Revertto != BG_CUSTOM)
            {		
                fail = true;
                ClearBackground();
                GetThumbnail();
            }
            break;	

        default:
            {
                fail = true;
                ClearBackground();
                GetThumbnail();                
            }
            break;
        }
    }

    if (tempfail)
    {
        return NULL;
    }

    REAL textheight = 0;
    Bitmap *canvas = background->Clone(0, 0, background->GetWidth(), background->GetHeight(), PixelFormat32bppPARGB);
    Graphics gfx(canvas);

    if (m_Settings.Text.empty())
    {
        Pen p(Color::MakeARGB(1, 255, 255, 255), 0.1);
        gfx.DrawLine(&p, 0, 0, 1, 1);
        textheight = m_iconheight + 10; 
    }
    else
    {
        // Draw text
        static lines text_parser(m_Settings, m_metadata, m_hwnd);
        text_parser.Parse();

        if (m_textpositions.empty())
        {
            m_textpositions.resize(text_parser.GetNumberOfLines(), 0);
        }
        else
        {
            for (std::vector<int>::size_type i = 0; i != m_textpositions.size(); ++i)
            {
                if (m_textpositions[i] != 0)
                {
                    m_textpositions[i] -= 2;
                }
                else
                {
                    if (scroll_block)
                    {
                        bool unblock = true;

                        for (std::vector<int>::size_type j = 0; j != m_textpositions.size(); ++j)
                        {
                            if (m_textpositions[j] < 0)
                            {
                                unblock = false;
                                break;
                            }                                
                        }

                        scroll_block = !unblock;
                        m_textpause = 60;
                    }

                    if (!scroll_block && m_textpause == 0)
                    {
                        m_textpositions[i] -= 2;
                    }
                }
            }
        }

        // Setup fonts	    
        HDC h_gfx = gfx.GetHDC();	    
        Font font(h_gfx, &m_Settings.font);

        LOGFONT large_font = {};
        large_font = m_Settings.font;	    

        LONG large_size = -((m_Settings.font.lfHeight * 72) / GetDeviceCaps(h_gfx, LOGPIXELSY));
        large_size += 4;
        large_font.lfHeight = -MulDiv(large_size, GetDeviceCaps(h_gfx, LOGPIXELSY), 72);
        Font largefont(h_gfx, &large_font);

        gfx.ReleaseHDC(h_gfx);

        SolidBrush bgcolor(Color(GetRValue(m_Settings.bgcolor), GetGValue(m_Settings.bgcolor), GetBValue(m_Settings.bgcolor)));
        SolidBrush fgcolor(Color(GetRValue(m_Settings.text_color), GetGValue(m_Settings.text_color), GetBValue(m_Settings.text_color)));

        StringFormat sf(StringFormatFlagsNoWrap);
        const int text_space = 28;

        for (std::size_t text_index = 0; text_index != text_parser.GetNumberOfLines(); ++text_index)
        {
            RectF ret_rect;
            std::wstring current_text = text_parser.GetLineText(text_index);
            linesettings current_settings = text_parser.GetLineSettings(text_index);

            // Measure size
            gfx.SetTextRenderingHint(TextRenderingHintAntiAlias);
            if (current_settings.largefont)
                gfx.MeasureString(current_text.c_str(), -1, &largefont, RectF(0, 0, 2000, 1000), &sf, &ret_rect);
            else
                gfx.MeasureString(current_text.c_str(), -1, &font, RectF(0, 0, 2000, 1000), &sf, &ret_rect);

            if (ret_rect.GetBottom() == 0)
            {
                if (current_text.empty())
                {
                    gfx.MeasureString(L"QWEXCyjM", -1, &font, RectF(0, 0, static_cast<REAL>(width), static_cast<REAL>(height)), &sf, &ret_rect);			
                }
                else
                {
                    gfx.MeasureString(L"QWEXCyjM", -1, &Font(L"Segoe UI", 14), RectF(0, 0, static_cast<REAL>(width), static_cast<REAL>(height)), &sf, &ret_rect);			
                }
            }

            Bitmap text_bitmap(ret_rect.GetRight(), ret_rect.GetBottom() - 1, PixelFormat32bppPARGB);
            Graphics text_gfx(&text_bitmap);

            // Graphics setup
            text_gfx.SetSmoothingMode(SmoothingModeNone);
            text_gfx.SetInterpolationMode(InterpolationModeNearestNeighbor);
            text_gfx.SetPixelOffsetMode(PixelOffsetModeNone);
            text_gfx.SetCompositingQuality(CompositingQualityHighSpeed);

            (m_Settings.Antialias) ? text_gfx.SetTextRenderingHint(TextRenderingHintAntiAlias) : 
                text_gfx.SetTextRenderingHint(TextRenderingHintSingleBitPerPixelGridFit);

            // Draw box if needed
            if (current_settings.darkbox && !current_text.empty())
            {
                SolidBrush boxbrush(Color::MakeARGB(120, GetRValue(m_Settings.bgcolor),
                    GetGValue(m_Settings.bgcolor), GetBValue(m_Settings.bgcolor)));

                ret_rect.Height += 2;
                text_gfx.FillRectangle(&boxbrush, ret_rect);
            }

            text_gfx.SetTextContrast(120);

            // Draw text to offscreen surface

            //shadow
            if (current_settings.shadow)
            {
                text_gfx.DrawString(current_text.c_str(), -1, 
                    current_settings.largefont ? &largefont : &font, 
                    PointF(1, -1), &bgcolor);
            }

            //text
            text_gfx.DrawString(current_text.c_str(), -1, 
                current_settings.largefont ? &largefont : &font, 
                PointF(0, -2), &fgcolor);

            // Calculate text position
            int X = 0, CX = width;

            if (m_iconwidth == 0)
            {
                m_iconwidth = iconsize;
            }

            if (m_iconheight == 0)
            {
                m_iconheight = iconsize;
            }

            if (m_Settings.AsIcon && !no_icon && !current_settings.forceleft)
            {
                if ( (iconposition == IP_UPPERLEFT || 
                    iconposition == IP_LOWERLEFT) &&
                    !current_settings.forceleft )
                {
                    X += m_iconwidth + 5;
                    CX = width - X;
                }
                else if ( iconposition == IP_UPPERRIGHT || 
                    iconposition == IP_LOWERRIGHT )
                {
                    CX = width - m_iconwidth - 5;
                }
            }

            gfx.SetClip(RectF(X, 0, CX, width), CombineModeReplace);

            // Draw text bitmap to final bitmap
            if (text_bitmap.GetWidth() > CX + 2 && !current_settings.dontscroll)// && m_textpause[text_index] == 0)
            {
                // Draw scrolling text
                int left = m_textpositions[text_index];
                int bmp_width = (int)text_bitmap.GetWidth();
                int bmp_height = (int)text_bitmap.GetHeight();

                if (left + bmp_width < 0)
                {
                    // reset text
                    m_textpositions[text_index] = text_space;
                    left = text_space;
                    scroll_block = true;
                }

                if (left == 0 && m_textpause == 0)
                {
                    m_textpause = 60; // delay; in steps
                }

                if (left + bmp_width >= CX)
                {
                    gfx.DrawImage(&text_bitmap, X, (int)textheight, -left, 0, CX, bmp_height, UnitPixel);
                }
                else
                {
                    gfx.DrawImage(&text_bitmap, X, (int)textheight, -left, 0, bmp_width + left,
                        bmp_height, UnitPixel);

                    gfx.DrawImage(&text_bitmap, X + text_space + 2 + bmp_width + left, (int)textheight, 0, 0,
                        -left, bmp_height, UnitPixel);
                }
            }
            else
            {
                // Draw non-scrolling text
                if (current_settings.center)
                {
                    // Center text
                    int newleft = X + ((CX / 2) - (text_bitmap.GetWidth() / 2));
                    gfx.DrawImage(&text_bitmap, newleft, (int)textheight, 0, 0, text_bitmap.GetWidth(), text_bitmap.GetHeight(), UnitPixel);          
                }
                else
                {
                    gfx.DrawImage(&text_bitmap, X, (int)textheight, 0, 0, text_bitmap.GetWidth(), text_bitmap.GetHeight(), UnitPixel);          
                }

                m_textpositions[text_index] = 2; // Nr. pixels text jumps on each step when scrolling
            }

            gfx.ResetClip();

            textheight += text_bitmap.GetHeight();
        }

        if (m_textpause > 0)
        {
            --m_textpause;
        }

        if (!m_Settings.Shrinkframe)	
            textheight = height-2;

        if (m_Settings.Thumbnailpb)
            textheight += 25;

        if (textheight > height-2)
            textheight = height-2;
    }

    // Draw progressbar
    if (m_Settings.Thumbnailpb && m_Settings.play_total > 0)// && m_Settings.play_current >0)
    {
        gfx.SetSmoothingMode(SmoothingModeAntiAlias);		
        int Y = canvas->GetHeight()-10;
        if (m_Settings.Shrinkframe)
        {
            Y = textheight - 10;
        }
        Pen p1(Color::White, 1);
        Pen p2(Color::MakeARGB(80, 0, 0, 0), 1);

        SolidBrush b1(Color::MakeARGB(50, 0, 0, 0));	
        SolidBrush b2(Color::MakeARGB(220, 255, 255, 255));

        RectF R1(44, (REAL)Y, 10, 9);
        RectF R2((REAL)width - 56, (REAL)Y, 10, 9);

        gfx.FillRectangle(&b1, 46, Y, width-94, 9);
        gfx.DrawLine(&p2, 46, Y+2, 46, Y+6);
        gfx.DrawLine(&p2, width-48, Y+2, width-48, Y+6);

        gfx.DrawArc(&p1, R1, -90.0f, -180.0f);
        gfx.DrawArc(&p1, R2, 90.0f, -180.0f);

        gfx.DrawLine(&p1, 48, Y, width-49, Y);
        gfx.DrawLine(&p1, 48, Y+9, width-49, Y+9);

        gfx.SetSmoothingMode(SmoothingModeDefault);
        gfx.FillRectangle(&b2, 48, Y+3, (m_Settings.play_current*(width-96))/m_Settings.play_total, 4);
    }

    // finalize / garbage    
    HBITMAP retbmp;

    if (!m_Settings.Shrinkframe)
    {
        canvas->GetHBITMAP(NULL, &retbmp);        
    }
    else
    {
        Bitmap *shrink = canvas->Clone(0, 0, (int)width, 
            textheight > m_iconheight ? (int)textheight : (int)m_iconheight, PixelFormat32bppPARGB);
        shrink->GetHBITMAP(NULL, &retbmp);
        delete shrink;
    }

    delete canvas;
    return retbmp;
}
Пример #18
0
void CCxBCGPMenuBar::LoadData()
{
	// 	static const LPCTSTR arrImageName[] = {
	// 		"NewProcess.png", "OpenProcess.png", "RunProcess.png",
	// 		"Preview.png", "Save.png", "DataLinker.png", "Monitor.png", 
	// 		"Help.png", "About.png" 
	// 	};

	static const LPCTSTR arrImageName[] = {
		"NewProcess.png", "OpenProcess.png", "Save.png", "DataLinker.png", 
		"RunProcess.png",
		"Monitor.png", "Preview.png", 
		//"About.png" ,
		"Help.png" ,
		"OpenComponent.png",
		"SaveAs.png",
		"Close.png",
		"Info.png",
		"Publish.png",
		"Exit.png"
	};

	CString strDir = GetExecDir() + "\\Res\\MainToolbar\\";
	Bitmap * pBitmap = NULL;
	HBITMAP hbmp = NULL;

	//ResetAll();

	ClearData();

	m_BCGToolbarImages.SetImageSize( CSize(16, 16) );

	//Color crImgBg;
	//crImgBg.SetFromCOLORREF(g_crToolbarBg);
	//Color crImgBg = Color::White;
	//m_BCGToolbarImages.SetTransparentColor (g_crToolbarBg);

	int nCount = sizeof( arrImageName ) / sizeof( LPCTSTR );
	for (int i=0; i<nCount; i++)
	{
		pBitmap = GetNewBitmap( strDir + arrImageName[i] );
		if ( pBitmap == NULL )
		{
			CString strLog;
			strLog.Format( "图片资源丢失,%s", arrImageName[i] );
			MessageBox( strLog, g_lpszAppTitle );

			ClearData();
			return;
		}
		m_vImages.push_back( pBitmap );
		//Color color(255,255,255,255);
		pBitmap->GetHBITMAP( NULL, &hbmp);
		if ( hbmp == NULL )
		{
			ClearData();
			return;
		}
		m_vHBitmaps.push_back( hbmp );
		m_BCGToolbarImages.AddImage( hbmp );
	}

	if ( m_BCGToolbarImages.GetCount() == 0 ) return;

	//SetSizes( CSize(32, 30), CSize(16, 16) );
	//SetMenuSizes( CSize(32, 22), CSize(13, 13));
	SetMenuSizes( CSize(32, 28), CSize(16, 16));
	//SetUserImages( &m_BCGToolbarImages );

	int nImgPos = m_Images.GetCount() > 0 ? m_Images.GetCount() : 0;

	for (int i=0; i<m_BCGToolbarImages.GetCount(); i++)
	{
		m_Images.AddImage( m_vHBitmaps[i] );
		m_ImagesLocked.AddImage( m_vHBitmaps[i] );
		m_LargeImages.AddImage( m_vHBitmaps[i] );
		m_LargeImagesLocked.AddImage( m_vHBitmaps[i] );
	}

	m_BCGToolbarImages.ConvertTo32Bits();
	m_Images.ConvertTo32Bits();
	m_ImagesLocked.ConvertTo32Bits();
	m_LargeImages.ConvertTo32Bits();
	m_LargeImagesLocked.ConvertTo32Bits();

	BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_NEW, 1, nImgPos + IMG_NEW_PROCESS);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_OPEN, 1, nImgPos + IMG_OPEN_PROCESS);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_SAVE, 1, nImgPos + IMG_SAVE);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_RUN, 1, nImgPos + IMG_RUN_PROCESS);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_TOOL_JOBMGR, 1, nImgPos + IMG_JOBMGR);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_DISTRIBUTION, 1, nImgPos + IMG_PREVIEW);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_HELP, 1, nImgPos + IMG_HELP);
	//BCGPCMD_MGR.EnableMenuItemImage(IDM_HELP_ABOUT, 1, nImgPos + IMG_ABOUT);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_TOOL_FLEXWARE, 1, nImgPos + IMG_COMPONENT);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_SAVEAS, 1, nImgPos + IMG_SAVEAS);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_INFO, 1, nImgPos + IMG_INFO);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_CLOSEALL, 1, nImgPos + IMG_CLOSE);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_PUBLISH, 1, nImgPos + IMG_PUBLISH);
	BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_EXIT, 1, nImgPos + IMG_EXIT);


}
Пример #19
0
HRESULT CustomUiGetPng(LPCWSTR resource_id, IPictureDisp ** result_image, IPictureDisp** result_mask)
{
	HMODULE hModule = AfxGetResourceHandle();
	HRESULT hr = S_OK;

	using namespace Gdiplus;

	PICTDESC pd = {0};
	pd.cbSizeofstruct = sizeof (PICTDESC);
	pd.picType = PICTYPE_BITMAP;

	GdiplusStartupInput gdiplusStartupInput;
	ULONG_PTR gdiplusToken;

	gdiplusStartupInput.DebugEventCallback = NULL;
	gdiplusStartupInput.SuppressBackgroundThread = FALSE;
	gdiplusStartupInput.SuppressExternalCodecs = FALSE;
	gdiplusStartupInput.GdiplusVersion = 1;
	GdiplusStartup (&gdiplusToken, &gdiplusStartupInput, NULL);

	HRSRC hResource = FindResource (hModule, resource_id, L"PNG");

	if (!hResource)
		return HRESULT_FROM_WIN32(GetLastError());

	DWORD dwImageSize = SizeofResource (hModule, hResource);

	const void* pResourceData = LockResource (LoadResource(hModule, hResource));
	if (!pResourceData)
		return HRESULT_FROM_WIN32(GetLastError());

	HGLOBAL hBuffer = GlobalAlloc (GMEM_MOVEABLE, dwImageSize);
	if (hBuffer)
	{
		void* pBuffer = GlobalLock (hBuffer);
		if (pBuffer)
		{
			CopyMemory (pBuffer, pResourceData, dwImageSize);

			IStream* pStream = NULL;
			if (::CreateStreamOnHGlobal (hBuffer, FALSE, &pStream) == S_OK)
			{
				Bitmap *bitmap = Bitmap::FromStream (pStream);
				pStream->Release();

				if (bitmap)
				{
					if (result_mask == NULL) // direct support for picture
					{
						bitmap->GetHBITMAP (0, &pd.bmp.hbitmap);
						hr = OleCreatePictureIndirect (&pd, IID_IDispatch, TRUE, (LPVOID*)result_image);
					}
					else	// old version - 2003/2007 - split into picture + mask
					{
						UINT w = bitmap->GetWidth();
						UINT h = bitmap->GetHeight();
						Rect r(0, 0, w, h);

						Bitmap bitmap_rgb(w, h, PixelFormat24bppRGB);
						Bitmap bitmap_msk(w, h, PixelFormat24bppRGB);

						BitmapData argb_bits;
						bitmap->LockBits(&r, ImageLockModeRead, PixelFormat32bppARGB, &argb_bits);

						BitmapData rgb_bits;
						bitmap_rgb.LockBits(&r, ImageLockModeWrite, PixelFormat24bppRGB, &rgb_bits);

						BitmapData msk_bits;
						bitmap_msk.LockBits(&r, ImageLockModeWrite, PixelFormat24bppRGB, &msk_bits);

						for (UINT y = 0; y < h; ++y)
						{
							for (UINT x = 0; x < w; ++x)
							{
								BYTE* idx_argb = 
									static_cast<BYTE*>(argb_bits.Scan0) + (x + y*w) * 4;

								BYTE* idx_rgb = 
									static_cast<BYTE*>(static_cast<BYTE*>(rgb_bits.Scan0) + (x + y*w) * 3);

								BYTE* idx_msk =
									static_cast<BYTE*>(static_cast<BYTE*>(msk_bits.Scan0) + (x + y*w) * 3);


								idx_rgb[0] = idx_argb[0];
								idx_rgb[1] = idx_argb[1];
								idx_rgb[2] = idx_argb[2];

								byte t = (idx_argb[3] < 128) ? 0xFF : 0x00;

								idx_msk[0] = t;
								idx_msk[1] = t;
								idx_msk[2] = t;
							}
						}

						bitmap->UnlockBits(&argb_bits);

						bitmap_rgb.UnlockBits(&rgb_bits);
						bitmap_msk.UnlockBits(&msk_bits);

						bitmap_rgb.GetHBITMAP (0, &pd.bmp.hbitmap);
						hr = OleCreatePictureIndirect (&pd, IID_IDispatch, TRUE, (LPVOID*)result_image);

						bitmap_msk.GetHBITMAP (0, &pd.bmp.hbitmap);
						hr = OleCreatePictureIndirect (&pd, IID_IDispatch, TRUE, (LPVOID*)result_mask);
					}


					delete bitmap;
				}
			}
			GlobalUnlock (pBuffer);
		}
		GlobalFree (hBuffer);
	}

	GdiplusShutdown (gdiplusToken);
	return hr;
}
Пример #20
0
void CCxBCGPMenuBar::LoadData()
{
    // 	static const LPCTSTR arrImageName[] = {
    // 		"NewProcess.png", "OpenProcess.png", "RunProcess.png",
    // 		"Preview.png", "Save.png", "DataLinker.png", "Monitor.png",
    // 		"Help.png", "About.png"
    // 	};

    static const LPCTSTR arrImageName[] = {
        //"ToolbarMessage.png"
        "ToolbarFlexware.png"
        , "ToolbarPortal.png"
        , "ToolbarSetting.png"
        , "ToolbarAbout.png"
    };

    CString strDir = GetExecDir() + "\\Res\\MainToolbar\\";
    Bitmap * pBitmap = NULL;
    HBITMAP hbmp = NULL;

    //ResetAll();

    ClearData();

    m_BCGToolbarImages.SetImageSize( CSize(30, 30) );

    Color crImgBg;
    crImgBg.SetFromCOLORREF(g_crToolbarBg);
    //Color crImgBg = Color::White;
    m_BCGToolbarImages.SetTransparentColor (g_crToolbarBg);

    int nCount = sizeof( arrImageName ) / sizeof( LPCTSTR );
    for (int i=0; i<nCount; i++)
    {
        pBitmap = GetNewBitmap( strDir + arrImageName[i] );
        if ( pBitmap == NULL )
        {
            ClearData();
            return;
        }
        m_vImages.push_back( pBitmap );
        //Color color(255,255,255,255);
        pBitmap->GetHBITMAP( crImgBg, &hbmp);
        if ( hbmp == NULL )
        {
            ClearData();
            return;
        }
        m_vHBitmaps.push_back( hbmp );
        m_BCGToolbarImages.AddImage( hbmp );
    }

    if ( m_BCGToolbarImages.GetCount() == 0 ) return;

    //SetSizes( CSize(32, 30), CSize(16, 16) );
    //SetMenuSizes( CSize(32, 22), CSize(13, 13));
    SetMenuSizes( CSize(36, 36), CSize(30, 30));
    //SetUserImages( &m_BCGToolbarImages );

    int nImgPos = m_Images.GetCount() > 0 ? m_Images.GetCount() : 0;

    for (int i=0; i<m_BCGToolbarImages.GetCount(); i++)
    {
        m_Images.AddImage( m_vHBitmaps[i] );
        m_ImagesLocked.AddImage( m_vHBitmaps[i] );
        m_LargeImages.AddImage( m_vHBitmaps[i] );
        m_LargeImagesLocked.AddImage( m_vHBitmaps[i] );
    }

    //BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_NEW, 1, nImgPos + IMG_TOOLBAR_MESSAGE);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_OPEN, 1, nImgPos + IMG_TOOLBAR_FLEXWARE);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_SAVE, 1, nImgPos + IMG_TOOLBAR_PORTAL);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_RUN, 1, nImgPos + IMG_RUN_PROCESS);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_TOOL_HISTORY_MONITOR, 1, nImgPos + IMG_HISTORY_MONITOR);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_DISTRIBUTION, 1, nImgPos + IMG_PREVIEW);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_HELP, 1, nImgPos + IMG_HELP);
    ////BCGPCMD_MGR.EnableMenuItemImage(IDM_HELP_ABOUT, 1, nImgPos + IMG_ABOUT);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_TOOL_FLEXWARE, 1, nImgPos + IMG_COMPONENT);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_SAVEAS, 1, nImgPos + IMG_SAVEAS);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_INFO, 1, nImgPos + IMG_INFO);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_CLOSEALL, 1, nImgPos + IMG_CLOSE);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_PUBLISH, 1, nImgPos + IMG_PUBLISH);
    //BCGPCMD_MGR.EnableMenuItemImage(IDM_TASK_EXIT, 1, nImgPos + IMG_EXIT);


}