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);
	}
}
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;
}
示例#3
0
//-------------------------------------------------------------------------------------
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() ;
}
示例#4
0
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
}
示例#5
0
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;
}
示例#6
0
文件: Meter.cpp 项目: pipetko/3RVX
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();
}
bool CTuoImage::LoadFromFile(LPCTSTR lpszFileName, bool bShortName)
{
	std::wstring strFileName = lpszFileName;

	if (bShortName)
	{
		if (g_strSkinDir.size() == 0)
		{
			TCHAR szPath[MAX_PATH] = { 0 };
			::GetModuleFileName(NULL, szPath, _countof(szPath));
			TCHAR *p = _tcsrchr(szPath, '\\');
			if (p) *p = 0;

			g_strSkinDir = szPath;
			g_strSkinDir += _T("\\Skin\\");
		}

	}

	strFileName = g_strSkinDir + strFileName;
	//Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromFile(lpszFileName);
	Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromFile(strFileName.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;
}
示例#8
0
void HostResourceLoader::loadFromPNG( BuiltFromResourcePixMap& item ) {
    HRSRC x = ::FindResourceA(  NULL, item.resourceName, "PNG" );
    ProductionAssert(x,item.resourceName);
    DWORD n = SizeofResource( NULL, x); 
    Assert(n);
    HGLOBAL g = ::LoadResource( NULL, x );
    Assert(g);
    const void* r=LockResource(g);
    Assert(r!=NULL);
    HGLOBAL buf = ::GlobalAlloc(GMEM_MOVEABLE, n);
    Assert(buf);
    char* png = (char*)::GlobalLock(buf);
    Assert(png);
    memcpy(png,r,n);
    // Following assertion check that it is a PNG resource.
    Assert(memcmp(png+1,"PNG",3)==0 );
    IStream* s = NULL;
    HRESULT streamCreationStatus = CreateStreamOnHGlobal(buf,FALSE,&s);
    Assert( streamCreationStatus==S_OK );
    Assert(s);
    Gdiplus::Bitmap* bitmap = Gdiplus::Bitmap::FromStream(s,FALSE);
    ProductionAssert(bitmap,"Gdiplus::Bitmap::FromStream returned false");
    Gdiplus::Status fromStreamStatus = bitmap->GetLastStatus();
    ProductionAssert(fromStreamStatus==Gdiplus::Ok,"Gdiplus::Bitmap::FromStream failed");
    s->Release();
    ::GlobalUnlock(buf);
    ::GlobalFree(buf);

    int w=bitmap->GetWidth();
    int h=bitmap->GetHeight();
    const Gdiplus::Rect rect(0,0,w,h);
    Gdiplus::BitmapData lockedBits;
    Gdiplus::Status lockStatus = bitmap->LockBits(&rect,0,PixelFormat32bppARGB,&lockedBits);
	Assert( lockStatus==Gdiplus::Ok);
    NimblePixMap map(w,h,8*sizeof(NimblePixel),lockedBits.Scan0,lockedBits.Stride);
    item.buildFrom(map);
	Gdiplus::Status unlockStatus = bitmap->UnlockBits(&lockedBits);
	delete bitmap;
	Assert(unlockStatus==Gdiplus::Ok);
    return;
}
示例#9
0
文件: SSkinGif.cpp 项目: 3rdexp/soui
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;
}
示例#10
0
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
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;
	switch (color_type)
	{
	case PNG_COLOR_TYPE_PALETTE:
		png_set_palette_to_rgb(png);
		pixelBytes = 4;
		break;
	case PNG_COLOR_TYPE_GRAY:
		png_set_expand_gray_1_2_4_to_8(png);
		pixelBytes = 3;
		break;
	case PNG_COLOR_TYPE_RGB:
		pixelBytes = 3;
		break;
	case PNG_COLOR_TYPE_RGBA:
		break;
	}

	uint8_t* image = new uint8_t[width * height * pixelBytes];
	uint32_t pitch = width * pixelBytes;

	/* イメージデータを読み込む */

	textureWidth = width;
	textureHeight = height;
	textureData.resize(textureWidth * textureHeight * 4);

	if (rev)
	{
		for (uint32_t i = 0; i < height; i++)
		{
			png_read_row(png, &image[(height - 1 - i) * pitch], NULL);
		}
	}
	else
	{
		for (uint32_t i = 0; i < height; i++)
		{
			png_read_row(png, &image[i * pitch], NULL);
		}
	}

	if (pixelBytes == 4)
	{
		memcpy(textureData.data(), image, width * height * pixelBytes);
	}
	else
	{
		for (int32_t y = 0; y < height; y++)
		{
			for (int32_t x = 0; x < width; x++)
			{
				int32_t src = (x + y * width) * 3;
				int32_t dst = (x + y * width) * 4;
				textureData[dst + 0] = image[src + 0];
				textureData[dst + 1] = image[src + 1];
				textureData[dst + 2] = image[src + 2];
				textureData[dst + 3] = 255;
			}
		}
	}
	
	delete [] image;
	png_destroy_read_struct(&png, &png_info, NULL);

	return true;
#endif
}
示例#11
0
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);
    }
    pTaskbarInterface->SetOverlayIcon(hWnd, icon, uuid.c_str());
    DestroyIcon(icon);
}
示例#12
0
//*************************************************************************************************************
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;
	}
示例#13
0
BOOL CPictureCtrl::Show(LPCTSTR pcszFile,UINT nDrawFlag)
{
	USES_CONVERSION;

	if (pcszFile == NULL)
	{
		if (m_nTimerId != 0)
		{
			KillTimer(m_nTimerId);
			m_nTimerId = 0;
		}

		if (m_pImage != NULL)
		{
			delete m_pImage;
			m_pImage = NULL;
			Invalidate(FALSE);
		}
			
		m_strFilePath.Empty();
		return TRUE;
	}
	else
	{
		Gdiplus::Bitmap *pSrcImage = Gdiplus::Bitmap::FromFile(T2CW(pcszFile));
		if (pSrcImage == NULL)
			return FALSE;

		if (pSrcImage->GetLastStatus() != Gdiplus::Ok)
		{
			delete pSrcImage;
			return FALSE;
		}

		Gdiplus::Bitmap *pImage = pSrcImage->Clone(0,0,pSrcImage->GetWidth(),
			pSrcImage->GetHeight(),def_gplusPixFormat);
		delete pSrcImage;
		if (pSrcImage == NULL)
			return FALSE;
		
		Show(NULL,0);
		m_nDrawFlag = nDrawFlag;
		m_pImage = pImage;

		UINT nDimCount = m_pImage->GetFrameDimensionsCount();
		
		CArray<GUID,GUID&> dimGuids;
		dimGuids.SetSize(nDimCount);
 
		m_pImage->GetFrameDimensionsList(dimGuids.GetData(), nDimCount);
		m_nFrameCount = pImage->GetFrameCount(dimGuids.GetData());
	
		if (m_nFrameCount > 1)
		{
			m_dimGuid = dimGuids[0];

			int nSize = pImage->GetPropertyItemSize(PropertyTagFrameDelay);
			m_propItem.SetSize(nSize); 

			pImage->GetPropertyItem(PropertyTagFrameDelay, nSize, 
				(Gdiplus::PropertyItem*)m_propItem.GetData());

			m_nCurFrame = 0;
			m_nTimerId = SetTimer(TIMER_ID,GetFrameDelay(),NULL);
		} 
 
		Invalidate(FALSE);
		m_dwSampleTick = GetTickCount();

		m_strFilePath = pcszFile;
		return TRUE;
	}
}