Пример #1
0
int CGameTitle::Init(void)
{
	for (int i=0;i<m_basicButtonKosuu;i++)
	{
		CPicture* lpPic = m_menu->GetPicture(i);
		LPSTR name = m_menu->GetFileName(i);
		char filename[256];
		wsprintf(filename,"sys\\%s",name);
		lpPic->LoadDWQ(filename);
	}

	m_menu->Init();

	m_commonParts->LoadDWQ("sys\\ta_title_bg");

	m_nekoX = 270.0f;
	m_nekoY = 800.0f;
	m_nekoHoukou = 90.0f;
	m_nekoKasoku = 0.0f;
	m_nekoCount = 0;

	m_nekoPointer = 0;
	for (int i=0;i<6;i++)
	{
		m_nekoZahyo[i*2] = -40.0f;
		m_nekoZahyo[i*2+1] = -40.0f;
		m_nekoMuki[i] = 0.0f;
	}

	return -1;
}
Пример #2
0
UINT AviConverter::run() {
  try {
    CPicture picture;
    picture.load(m_nameArray[0]);
    const CSize imageSize = picture.getSize();

    HDC screenDC = getScreenDC();
    m_dc     = CreateCompatibleDC(screenDC);
    m_bitmap = CreateCompatibleBitmap(screenDC, imageSize.cx, imageSize.cy);
    DeleteDC(screenDC);
    DWORD codec = 0; // mmioFOURCC('w','m','v',' ');

    if(ACCESS(m_outFileName, 0) == 0) {
      UNLINK(m_outFileName);
    }
    CAviFile aviFile(m_outFileName, true, codec, m_framesPerSecond);

    for(m_index = 0; m_index < (int)m_nameArray.size(); m_index += m_useEvery) {
      if(isInterrupted()) {
        throwException(_T("Interrupted by user"));
      }
      picture.load(m_nameArray[m_index]);
      HGDIOBJ oldGDI = SelectObject(m_dc, m_bitmap);
      picture.show(m_dc);
      SelectObject(m_dc, oldGDI);
      aviFile.appendNewFrame(m_bitmap);
    }
  } catch(Exception e) {
    m_ok  = false;
    m_msg = e.what();
  }
  return 0;
}
Пример #3
0
STDMETHODIMP CPictHolder::OpenPictureFile(BSTR strPicture)
{
    Close();
    CString S( strPicture );
    if( !m_fileOfPicture.Open( S, CFile::modeRead | CFile::typeBinary ) )
        return E_FAIL;
    CRuntimeClass	*pRT;
    CPicture		*pPict = NULL;
    HRESULT	hr = E_FAIL;
    try {
        for(;;) {
            if( NULL == ( pRT = GetWritablePictureType( &m_fileOfPicture ) ) )
                break;
            pPict = (CPicture*) pRT->CreateObject();
            VERIFY( pPict->Attach( &m_fileOfPicture ) && pPict->ReadHeader() );
            m_pPicture = pPict;
            hr = S_OK;
            break;
        }
    } catch(...) {
        if( pPict )
            delete pPict;
        m_pPicture = NULL;
    }
    return hr;
}
Пример #4
0
bool CProgramThumbLoader::LoadItem(CFileItem *pItem)
{
  if (pItem->m_bIsShareOrDrive) return true;
  if (!pItem->HasThumbnail())
    pItem->SetUserProgramThumb();
  else
  {
    // look for remote thumbs
    CStdString thumb(pItem->GetThumbnailImage());
    if (!CURL::IsFileOnly(thumb) && !CUtil::IsHD(thumb))
    {
      CStdString cachedThumb(pItem->GetCachedProgramThumb());
      if(CFile::Exists(cachedThumb))
        pItem->SetThumbnailImage(cachedThumb);
      else
      {
        CPicture pic;
        if(pic.DoCreateThumbnail(thumb, cachedThumb))
          pItem->SetThumbnailImage(cachedThumb);
        else
          pItem->SetThumbnailImage("");
      }
    }  
  }
  
  if (!pItem->HasProperty("fanart_image"))
  {
    pItem->CacheFanart();
    if (CFile::Exists(pItem->GetCachedFanart()))
      pItem->SetProperty("fanart_image",pItem->GetCachedFanart());
  }
  
  return true;
}
Пример #5
0
static bool GetReferenced( CFile& rFile, CString& rString, TOPOMAP& theMap ) {
	CRuntimeClass	*pRT;
	if( NULL == ( pRT = GetPictureType( &rFile ) ) );
	CPicture	*pPict = (CPicture*) pRT->CreateObject();
	VERIFY( pPict->Attach( &rFile ) && pPict->ReadHeader() );
	long X0, Y0, X1, Y1;
	TAG	tag270;
	GetPictInfo( pPict, X0, Y0, X1, Y1);
	if( pPict->GetTag( 270, tag270 ) ) {
		rString = tag270.strVal();
	}
	delete pPict;
	//////////////////////////////////////////////////////////////////
	// Karteninformation basteln
	theMap.m_sizeOfPicture.cx = X1;
	theMap.m_sizeOfPicture.cy = Y1;
	// GCP's: LinksUnten, RechtsUnten, RechtsOben, LinksOben
	GEOPOINT	LO, RU;
	LO.X = 0; LO.Y = 0;
	RU.X = 0; RU.Y = 0;
	theMap.m_listOfGCP.erase( theMap.m_listOfGCP.begin(), theMap.m_listOfGCP.end() );
	theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( LO.X, RU.Y, 0 ),  GEOPOINT(  0, Y1, 0 ) ) );
	theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( RU.X, RU.Y, 0 ),  GEOPOINT( X1, Y1, 0 ) ) );
	theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( RU.X, LO.Y, 0 ),  GEOPOINT( X1,  0, 0 ) ) );
	theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( LO.X, LO.Y, 0 ),  GEOPOINT(  0,  0, 0 ) ) );
	return true;
}
Пример #6
0
static bool GetIntergraph( CFile& rFile, CString& rString, TOPOMAP& theMap ) {
	CRuntimeClass	*pRT;
	bool	bRet = false;
	if( NULL == ( pRT = GetPictureType( &rFile ) ) );
	CPicture	*pPict = (CPicture*) pRT->CreateObject();
	VERIFY( pPict->Attach( &rFile ) && pPict->ReadHeader() );
	long X0, Y0, X1, Y1;
	TAG	tag270;
	TAG tag33918;
	GetPictInfo( pPict, X0, Y0, X1, Y1);
	if( pPict->GetTag( 33918, tag33918 ) ) {
		long	nItems = tag33918.Count();
		if( ( 4 + 64 ) == nItems ) {
			IGTAG33918*	pData = (IGTAG33918*) tag33918.pVal();
			_ASSERTE(sizeof(theMap.m_transform.m_matrix) == sizeof(pData->dblVal) );
			memcpy( theMap.m_transform.m_matrix, pData->dblVal, sizeof(theMap.m_transform.m_matrix) );
			//////////////////////////////////////////////////////////////////
			// Karteninformation basteln
			theMap.m_sizeOfPicture.cx = X1;
			theMap.m_sizeOfPicture.cy = Y1;
			// GCP's: LinksUnten, RechtsUnten, RechtsOben, LinksOben
			theMap.m_listOfGCP.erase( theMap.m_listOfGCP.begin(), theMap.m_listOfGCP.end() );
			theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( ),  GEOPOINT(  0, Y1, 0 ) ) );
			theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( ),  GEOPOINT( X1, Y1, 0 ) ) );
			theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( ),  GEOPOINT( X1,  0, 0 ) ) );
			theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( ),  GEOPOINT(  0,  0, 0 ) ) );
			bRet = true;
		}
	}
	delete pPict;
	return bRet;
}
Пример #7
0
	TBool IsLegalBreakBeforeL(TInt aTextPosition, TInt aPreceedingClass,
		TBool aHasSpaces)
		{
		CPicture* pic = iSource->PictureL(iDocPos + aTextPosition);
		if (pic)
			return pic->LineBreakPossible(aPreceedingClass, ETrue, aHasSpaces);
		return ETrue;
		}
Пример #8
0
	TBool IsLegalBreakAfterL(TInt aTextPosition, TInt aFollowingClass,
		TBool aHasSpaces)
		{
		CPicture* pic = iSource->PictureL(iDocPos + aTextPosition);
		if (pic)
			return pic->LineBreakPossible(aFollowingClass, EFalse, aHasSpaces);
		return ETrue;
		}
Пример #9
0
HRESULT CDockingTabFrame::AddTabWindow(INT_PTR hWnd, BSTR bstrName, VARIANT vPict, INT_PTR *phHandle)
{
	if (NULL == phHandle)
		return E_POINTER;
	*phHandle = NULL;

	USES_CONVERSION;
	COM_TRY {
		if (SUCCEEDED(FindTabWindow(bstrName, phHandle)) && hWnd == *phHandle)
			return S_FALSE;		// existierte bereits

		*phHandle = NULL;		// doch nichts

	// neue TablaschenDaten erzeugen
		_ASSERTE(::IsWindow(reinterpret_cast<HWND>(hWnd)));

	CTabData *pTabData = new CTabData;
	CWnd *pWnd = CWnd::FromHandlePermanent(reinterpret_cast<HWND>(hWnd));

		if (NULL == pWnd) {
		// hWnd ist kein MFC-Fenster
			pWnd = new CWnd;
			pWnd -> Attach(reinterpret_cast<HWND>(hWnd));	// trägt hWnd in CWndMap ein
			pTabData -> m_fIsAttached = true;
			pTabData -> m_pWnd = pWnd;
			pTabData -> m_hOldParentWnd = ::GetParent(reinterpret_cast<HWND>(hWnd));

			pWnd -> SetParent(&m_wndTab);
		} 
		else {
			pTabData -> m_fIsAttached = false;
			pTabData -> m_pWnd = pWnd;
			pTabData -> m_hOldParentWnd = NULL;
		}

	// erzeugen der TabLasche, speichern der eigenen Daten
	SECTab *pTab = m_wndTab.AddTab(pWnd, OLE2A(bstrName));

		pTab -> m_pExtra = pTabData;

	// ggf. Bildchen hinzufügen
	WPictureDisp PictDisp;

		if (SUCCEEDED(RetrievePicture(vPict, PictDisp.ppi()))) {
		CPicture Pict (PictDisp, false);

			_ASSERTE(NULL != Pict.GetHandle());
			m_wndTab.SetTabIcon(m_wndTab.GetTabCount()-1, reinterpret_cast<HICON>(Pict.GetHandle()));
		}

	// Erfolg: Fensterhandle wieder zurückliefern
		*phHandle = hWnd;

	} COM_CATCH;
	return S_OK;
}
Пример #10
0
LRESULT VerifyImgDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
    gvidlg = this;
    CenterWindow(GetParent());
    picwnd_.SubclassWindow(GetDlgItem(IDC_IMAGE1));

    CPicture pic;
    pic.Load(_T("C:\\w\\infostudio\\InfoStudio\\test\\msdn.bmp"));
    picwnd_.SetPicture(pic);
    return TRUE;
}
Пример #11
0
/*
* 添加一张图片
*/
bool CYuanListShowImg::AddImg(char *pImgPath)
{
	{
	//	GetScaleBitmap(pImgPath, m_nImgWidth, m_nImgHeight);
	}
	int bef = m_imList.GetImageCount();
	
	CPicture pic;
	int nRet = 0;
	CBitmap * pBmp = NULL; 

	/*pBmp = new CBitmap();  
	HBITMAP bmp = NULL;
	bmp = pic.LoadPicture(pImgPath);
	nRet = pBmp->Attach(bmp);*/

	//必须放外面。不然指针会被销毁导致不显示图案
	HBITMAP bmp = NULL;
	bmp = pic.LoadPicture(pImgPath);

	pBmp = GetScaleBitmap(bmp, m_nImgWidth, m_nImgHeight);
	if(NULL == pBmp)
	{
		// 插入失败时,必须插入一张默认的图片,不然后面的图片序号会往上移动
		// 导致图片显示错乱
		nRet = m_imList.Add(m_pDefaultBmp,RGB(0,0,0));  
		return true;
	}
	
	nRet = m_imList.Add(pBmp,RGB(0,0,0));  

	if (nRet == -1)
	{
		// 插入失败时,必须插入一张默认的图片,不然后面的图片序号会往上移动
		// 导致图片显示错乱
		nRet = m_imList.Add(m_pDefaultBmp,RGB(0,0,0));  
	}
	else
	{
		int aft = m_imList.GetImageCount();
		if(bef==aft)
		{
			nRet = m_imList.Add(m_pDefaultBmp,RGB(0,0,0));
		}
	}
	delete pBmp; 

	if (nRet == -1)
		return false;
	return true;
}
Пример #12
0
void CLastFmManager::CacheTrackThumb(const int nrInitialTracksToAdd)
{
  DWORD start = timeGetTime();
  CSingleLock lock(m_lockCache);
  int iNrCachedTracks = m_RadioTrackQueue->size();
  CPicture pic;
  CHTTP http;
  for (int i = 0; i < nrInitialTracksToAdd && i < iNrCachedTracks; i++)
  {
    CFileItemPtr item = (*m_RadioTrackQueue)[i];
    if (!item->GetMusicInfoTag()->Loaded())
    {
      //cache albumthumb, GetThumbnailImage contains the url to cache
      if (item->HasThumbnail())
      {
        CStdString coverUrl = item->GetThumbnailImage();
        CStdString crcFile;
        CStdString cachedFile;
        CStdString thumbFile;

        Crc32 crc;
        crc.ComputeFromLowerCase(coverUrl);
        crcFile.Format("%08x.tbn", (__int32)crc);
        CUtil::AddFileToFolder(_P(g_advancedSettings.m_cachePath), crcFile, cachedFile);
        CUtil::AddFileToFolder(g_settings.GetLastFMThumbFolder(), crcFile, thumbFile);
        item->SetThumbnailImage("");
        try
        {
          //download to temp, then make a thumb
          if (CFile::Exists(thumbFile) || (http.Download(coverUrl, cachedFile) && pic.DoCreateThumbnail(cachedFile, thumbFile)))
          {
            if (CFile::Exists(cachedFile)) CFile::Delete(cachedFile);
            item->SetThumbnailImage(thumbFile);
          }
        }
        catch(...)
        {
          CLog::Log(LOGERROR, "LastFmManager: exception while caching %s to %s.", coverUrl.c_str(), thumbFile.c_str());
        }
      }
      if (!item->HasThumbnail())
      {
        item->SetThumbnailImage("defaultAlbumCover.png");
      }
      item->GetMusicInfoTag()->SetLoaded();
    }
  }
  CLog::Log(LOGDEBUG, "%s: Done (time: %i ms)", __FUNCTION__, (int)(timeGetTime() - start));
}
Пример #13
0
STDMETHODIMP CToolBarButton::GetImage (long *phBitmap, int *piCnt, int *piOffset)
{
	if (NULL == phBitmap) return E_POINTER;

	if (BUTTONSTYLE_SEPARATOR == m_tb.fsStyle)
		return E_FAIL;		// Separatoren haben keine Bitmap

CPicture Pict (m_PictDisp, false);

	ATLTRY(*phBitmap = Pict.GetHandle());
	if (NULL != piCnt) *piCnt = m_iCnt;
	if (NULL != piOffset) *piOffset = m_iOffset;

	return (NULL != *phBitmap) ? NOERROR : E_FAIL;
}
Пример #14
0
/// This method queries imdb for movie poster art associated with an imdb number
bool CMediaMonitor::imdb_GetMovieArt(CStdString& strPath, CStdString& strPictureUrl, CStdString& strImagePath)
{
  CFileItem item(strPath, false);
  item.SetVideoThumb();

  if (item.HasThumbnail())
  {
    strImagePath = item.GetThumbnailImage();
    return true;
  }

  CStdString strThum(item.GetCachedVideoThumb());

  CStdString strExtension;
  CUtil::GetExtension(strPictureUrl, strExtension);

  if (strExtension.IsEmpty())
  {
    return false;
  }

  CStdString strTemp;
  strTemp.Format("Z:\\ram_temp%s", strExtension.c_str());
  ::DeleteFile(strTemp.c_str());

  CHTTP http;
  http.Download(strPictureUrl, strTemp);

  try
  {
    CPicture picture;
    picture.DoCreateThumbnail(strTemp, strThum);
  }
  catch (...)
  {
    ::DeleteFile(strThum.c_str());
  }

  ::DeleteFile(strTemp.c_str());

  if (CFile::Exists(strThum.c_str()))
  {
    strImagePath = strThum;
    return true;
  }

  return false;
}
Пример #15
0
/** Draw the picture onto the graphics context.
@param aGc The graphics context.
@param aTopLeft Coordinates of the top left corner pixel of the picture.
@param aRect A clipping rectangle that defines the area to draw the picture.
@param aDevice The device map for the graphics device. It provides
the scaling to apply to the picture.
@param aPicture The drawable object.

@see CPicture::Draw
*/
EXPORT_C void MTmCustom::DrawPicture(CGraphicsContext& aGc,
	const TPoint& aTopLeft, const TRect& aRect,
	MGraphicsDeviceMap& aDevice, const CPicture& aPicture) const
	{
	aGc.SetClippingRect(aRect);
	aPicture.Draw(aGc, aTopLeft, aRect, &aDevice);
	}
Пример #16
0
bool CPictureThumbLoader::LoadItem(CFileItem* pItem)
{
  if (pItem->m_bIsShareOrDrive) return true;
  pItem->SetCachedPictureThumb();
  
  if(pItem->HasThumbnail())
  {
    CStdString thumb(pItem->GetThumbnailImage());

    // look for remote thumbs    
    if (!CURL::IsFileOnly(thumb) && !CUtil::IsHD(thumb))
    {
      CStdString cachedThumb(pItem->GetCachedPictureThumb());
      if(CFile::Exists(cachedThumb))
        pItem->SetThumbnailImage(cachedThumb);
      else
      {
        // see if we have additional info to download this thumb with
        if (pItem->HasVideoInfoTag())
          return DownloadVideoThumb(pItem, cachedThumb);
        else
        {
          CPicture pic;
          if(pic.DoCreateThumbnail(thumb, cachedThumb))
            pItem->SetThumbnailImage(cachedThumb);
          else
            pItem->SetThumbnailImage("");
        }
      }
    }
    else if (m_regenerateThumbs)
    {
      CFile::Delete(thumb);
      pItem->SetThumbnailImage("");
    }
  }

  if ((pItem->IsPicture() && !pItem->IsZIP() && !pItem->IsRAR() && !pItem->IsCBZ() && !pItem->IsCBR() && !pItem->IsPlayList()) && !pItem->HasThumbnail())
  { // load the thumb from the image file
    CPicture pic;
    pic.DoCreateThumbnail(pItem->m_strPath, pItem->GetCachedPictureThumb());
  }
  // refill in the thumb to get it to update
  pItem->SetCachedPictureThumb();
  pItem->FillInDefaultIcon();
  return true;
}
Пример #17
0
bool CFanart::DownloadImage(const CStdString &url, const CStdString &destination) const
{
  // Ideally we'd just call CPicture::CacheImage() directly, but for some
  // reason curl doesn't seem to like downloading these for us
  CHTTP http;
#ifdef RESAMPLE_CACHED_IMAGES
  CStdString tempFile = _P("Z:\\fanart_download.jpg");
  if (http.Download(url, tempFile))
  { 
    CPicture pic;
    pic.CacheImage(tempFile, destination);
    XFILE::CFile::Delete(tempFile);
    return true;
  }
  return false;
#else
  return http.Download(url, destination);
#endif
}
Пример #18
0
void CPicturePool::LoadImage()
{
    CPictureMap picMap;
    std::map<std::string, PictureNode> mapPicture;
    TCHAR filePath[MAX_PATH] = {0};
    ::GetModuleFileName(0, filePath, MAX_PATH);
    ::PathRemoveFileSpec(filePath);
    ::PathAppend(filePath, _T("Resource\\picture.xml"));
    picMap.LoadXml(filePath, mapPicture);
    for (auto i = mapPicture.begin(); i != mapPicture.end(); ++i)
    {
        CPicture* pPic = new CPicture();
        pPic->LoadBitmap(
            i->second.strPath.c_str(),
            RGB(i->second.r, i->second.g, i->second.b),
            i->second.width, i->second.height);
        m_mapPic[i->first] = pPic;
    }
}
Пример #19
0
bool CThumbLoader::LoadRemoteThumb(CFileItem *pItem)
{
  // look for remote thumbs
  CStdString thumb(pItem->GetThumbnailImage());
  if (!g_TextureManager.CanLoad(thumb))
  {
    CStdString cachedThumb(pItem->GetCachedVideoThumb());
    if (CFile::Exists(cachedThumb))
      pItem->SetThumbnailImage(cachedThumb);
    else
    {
      CPicture pic;
      if(pic.DoCreateThumbnail(thumb, cachedThumb))
        pItem->SetThumbnailImage(cachedThumb);
      else
        pItem->SetThumbnailImage("");
    }
  }
  return pItem->HasThumbnail();
}
Пример #20
0
void CDetectDVDMedia::SetNewDVDShareUrl( const CStdString& strNewUrl, bool bCDDA, const CStdString& strDiscLabel )
{
  CStdString strDescription = "DVD";
  if (bCDDA) strDescription = "CD";

  if (strDiscLabel != "") strDescription = strDiscLabel;

  // store it in case others want it
  m_diskLabel = strDescription;
  m_diskPath = strNewUrl;

  // delete any previously cached disc thumbnail
  CStdString strCache = _P("Z:\\dvdicon.tbn");
  if (CFile::Exists(strCache))
    CFile::Delete(strCache);

  // find and cache disc thumbnail, and update label to xbe label if applicable
  if ((g_advancedSettings.m_usePCDVDROM || IsDiscInDrive()) && !bCDDA)
  {
    // update disk label to xbe label if we have that info
    if (CFile::Exists("D:\\default.xbe"))
      CUtil::GetXBEDescription("D:\\default.xbe", m_diskLabel);

    // and get the thumb
    CStdString strThumb;
    CStdStringArray thumbs;
    StringUtils::SplitString(g_advancedSettings.m_dvdThumbs, "|", thumbs);
    for (unsigned int i = 0; i < thumbs.size(); ++i)
    {
      CUtil::AddFileToFolder(m_diskPath, thumbs[i], strThumb);
      CLog::Log(LOGDEBUG,"%s: looking for disc thumb:[%s]", __FUNCTION__, strThumb.c_str());
      if (CFile::Exists(strThumb))
      {
        CLog::Log(LOGDEBUG,"%s: found disc thumb:[%s], caching as:[%s]", __FUNCTION__, strThumb.c_str(), strCache.c_str());
        CPicture pic;
        pic.DoCreateThumbnail(strThumb, strCache);
        break;
      }
    }
  }
}
Пример #21
0
int MapInfo( const int argc, const char *argv[], istream& s_in, ostream& s_out, ostream& s_err ) {
	int		c;
	bool	bRaw = false;
	LPCTSTR	optarg;
	int		optind = 1;

	while( EOF != ( c = getopt( argc, argv, "rg?", optind, optarg ) ) ) {
		switch( c ) {
		case 'r' :	bRaw = true; break;
		case 'g' :	setlocale( LC_ALL, _T("German") ); break;
		case '?' :	Usage( s_err ); return TRUE;
		}
	}
	if( argc < optind ) {
		Usage( s_err );
		return FALSE;
	}
	CMemBlock		memPict( Size4MB );
	CRuntimeClass	*pRT;
	CPicture		*pPict;
	CFile			fileInput;
	for( ; optind < argc; optind++ ) {
		if( fileInput.Open( argv[optind], CFile::modeRead | CFile::typeBinary ) ) {
			pRT = ::GetPictureType( &fileInput );
			if( NULL != pRT && NULL != ( pPict = (CPicture*) pRT->CreateObject() ) ) {
				VERIFY( pPict->Attach( &fileInput ) && pPict->ReadHeader() );
				pPict->DumpTags( s_out, bRaw );
				pPict->Detach();
				delete pPict;
			} else {
				s_err << _T("cannot determine FileType: ") << argv[optind] << endl;
			}
			fileInput.Close();
		} else {
			s_err << _T("cannot open File: ") << argv[optind] << endl;
		}
	}
	return TRUE;
}
Пример #22
0
static bool ReduceOneMapFile( LPCTSTR lpszInFile, LPCTSTR lpszOutFile, PICTSAMPLEPARAM &fp, int level) 
{
	BOOL	bRet;
	CMemBlock	memInput( Size4MB );
	CMemBlock	memOutput( Size2MB );

	CRuntimeClass	*pInRT;
	CRuntimeClass	*pOutRT = NULL;

	CPicture		*pInPict;
	CPicture		*pOutPict;

	CFile		fileInput;
	CFile		fileOutput;


	CPictSample	filter;

	if( fileInput.Open( lpszInFile, CFile::modeRead | CFile::typeBinary ) ) {
		pInRT = ::GetWritablePictureType( &fileInput );
		if( NULL == pOutRT )
			pOutRT = pInRT;
		if( NULL != pInRT && NULL != ( pInPict = (CPicture*) pInRT->CreateObject() ) ) {
			if( fileOutput.Open( lpszOutFile, CFile::modeReadWrite | CFile::modeCreate | CFile::typeBinary ) ) {
				VERIFY( NULL != ( pOutPict = (CPicture*) pOutRT->CreateObject() ) );
				if( pInPict->Attach( &fileInput ) && pInPict->ReadHeader() ) {
					if( pOutPict->Attach( &fileOutput ) ) {
						switch( pInPict->GetBitsPerSample() ) {
						case 1 : fp.sampleParam = 0; break;
//						case 8 : fp.sampleParam = level > 2 ? 3 : 0; break;     // #HK050104
//						case 8 : fp.sampleParam = level <= 2 ? 3 : 0; break;     // #HK050120
						case 8 : fp.sampleParam = 3; break;     // #HK050120
						}
						filter.SetFilterData( &fp.p );
						bRet = filter.Filter( pInPict, pOutPict );
						pOutPict->Detach();
					}
					pInPict->Detach();
				}
				fileOutput.Close();
				delete pOutPict;
			}
			delete pInPict;
		}
		fileInput.Close();
	}
	return TRUE == bRet ? 1 : 0;
}
Пример #23
0
bool CScraperUrl::DownloadThumbnail(const CStdString &thumb, const CScraperUrl::SUrlEntry& entry)
{
    if (entry.m_url.IsEmpty())
        return false;

    CHTTP http;
    http.SetReferer(entry.m_spoof);
    string thumbData;
    if (http.Get(entry.m_url, thumbData))
    {
        try
        {
            CPicture picture;
            picture.CreateThumbnailFromMemory((const BYTE *)thumbData.c_str(), thumbData.size(), CUtil::GetExtension(entry.m_url), thumb);
            return true;
        }
        catch (...)
        {
            ::DeleteFile(thumb.c_str());
        }
    }
    return false;
}
Пример #24
0
void CGUIWindowMusicNav::SetThumb(int iItem, CONTEXT_BUTTON button)
{
  CFileItem* pItem = m_vecItems->Get(iItem);
  CFileItemList items;
  CStdString picturePath;
  CStdString strPath=pItem->m_strPath;
  CStdString strThumb;
  CStdString cachedThumb;

  if (button == CONTEXT_BUTTON_SET_ARTIST_THUMB)
  {
    long idArtist = -1;
    if (pItem->IsMusicDb())
    {
      CUtil::RemoveSlashAtEnd(strPath);
      int nPos=strPath.ReverseFind("/");
      if (nPos>-1)
      {
        //  try to guess where the user should start
        //  browsing for the artist thumb
        idArtist=atol(strPath.Mid(nPos+1));
      }
    }
    else if (pItem->IsVideoDb())
      idArtist = m_musicdatabase.GetArtistByName(pItem->GetLabel());

    m_musicdatabase.GetArtistPath(idArtist, picturePath);

    cachedThumb = pItem->GetCachedArtistThumb();

    CArtist artist;
    m_musicdatabase.GetArtistInfo(idArtist,artist);
    int i=1;
    for (std::vector<CScraperUrl::SUrlEntry>::iterator iter=artist.thumbURL.m_url.begin();iter != artist.thumbURL.m_url.end();++iter)
    {
      CStdString thumbFromWeb;
      CStdString strLabel;
      strLabel.Format("allmusicthumb%i.jpg",i);
      CUtil::AddFileToFolder("z:\\", strLabel, thumbFromWeb);
      if (CScraperUrl::DownloadThumbnail(thumbFromWeb,*iter))
      {
        CStdString strItemPath;
        strItemPath.Format("thumb://Remote%i",i++);
        CFileItem *item = new CFileItem(strItemPath, false);
        item->SetThumbnailImage(thumbFromWeb);
        CStdString strLabel;
        item->SetLabel(g_localizeStrings.Get(20015));
        items.Add(item);
      }
    }
  }
  else
  {
    strPath = m_vecItems->Get(iItem)->m_strPath;
    strPath.Replace("plugin://music/","Q:\\plugins\\music\\");
    strPath.Replace("/","\\");
    picturePath = strPath;
    CFileItem item(strPath,true);
    cachedThumb = item.GetCachedProgramThumb();
  }

  if (XFILE::CFile::Exists(cachedThumb))
  {
    CFileItem *item = new CFileItem("thumb://Current", false);
    item->SetThumbnailImage(cachedThumb);
    item->SetLabel(g_localizeStrings.Get(20016));
    items.Add(item);
  }

  if (button == CONTEXT_BUTTON_SET_PLUGIN_THUMB)
  {
    if (items.Size() == 0)
    {
      CFileItem item2(strPath,false);
      CUtil::AddFileToFolder(strPath,"default.py",item2.m_strPath);
      if (XFILE::CFile::Exists(item2.GetCachedProgramThumb()))
      {
        CFileItem *item = new CFileItem("thumb://Current", false);
        item->SetThumbnailImage(item2.GetCachedProgramThumb());
        item->SetLabel(g_localizeStrings.Get(20016));
        items.Add(item);
      }
    }

    CUtil::AddFileToFolder(strPath,"default.tbn",strThumb);
    if (XFILE::CFile::Exists(strThumb))
    {
      CFileItem* item = new CFileItem(strThumb,false);
      item->SetThumbnailImage(strThumb);
      item->SetLabel(g_localizeStrings.Get(20017));
      items.Add(item);
    }
  }

  CUtil::AddFileToFolder(picturePath,"folder.jpg",strThumb);
  if (XFILE::CFile::Exists(strThumb))
  {
    CFileItem* pItem = new CFileItem(strThumb,false);
    pItem->SetLabel(g_localizeStrings.Get(20017));
    pItem->SetThumbnailImage(strThumb);
    items.Add(pItem);
  }

  CFileItem* nItem = new CFileItem("thumb://None",false);
  nItem->SetLabel(g_localizeStrings.Get(20018));
  if (button == CONTEXT_BUTTON_SET_ARTIST_THUMB)
    nItem->SetThumbnailImage("DefaultArtistBig.png");
  else
    nItem->SetThumbnailImage("DefaultFolderBig.png");
  items.Add(nItem);

  if (CGUIDialogFileBrowser::ShowAndGetImage(items, g_settings.m_musicSources,
                                             g_localizeStrings.Get(20019), picturePath))
  {
    CPicture picture;
    if (picturePath.Equals("thumb://Current"))
      return;

    if (picturePath.Equals("thumb://None"))
    {
      XFILE::CFile::Delete(cachedThumb);
      if (button == CONTEXT_BUTTON_SET_PLUGIN_THUMB)
      {
        CPicture picture;
        picture.CacheSkinImage("DefaultFolderBig.png",cachedThumb);
        CFileItem item2(strPath,false);
        CUtil::AddFileToFolder(strPath,"default.py",item2.m_strPath);
        XFILE::CFile::Delete(item2.GetCachedProgramThumb());
      }
    }
    else if (button == CONTEXT_BUTTON_SET_PLUGIN_THUMB)
      XFILE::CFile::Cache(picturePath,cachedThumb);

    if (picturePath.Equals("thumb://None") ||
        picture.DoCreateThumbnail(items.Get(picturePath)->GetThumbnailImage(), cachedThumb))
    {
      CMusicDatabaseDirectory dir;
      dir.ClearDirectoryCache(m_vecItems->m_strPath);
      CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS);
      g_graphicsContext.SendMessage(msg);
      Update(m_vecItems->m_strPath);
    }
    else
      CLog::Log(LOGERROR, " %s Could not cache artist/plugin thumb: %s", __FUNCTION__, picturePath.c_str());
  }
}
Пример #25
0
bool CVideoThumbLoader::LoadItem(CFileItem* pItem)
{
 
  if (pItem->m_bIsShareOrDrive) return true;
  CStdString cachedThumb(pItem->GetCachedVideoThumb());

  if (!pItem->HasThumbnail())
  {
    pItem->SetUserVideoThumb();
    if (!CFile::Exists(cachedThumb))
    {
      CStdString strPath, strFileName;
      CUtil::Split(cachedThumb, strPath, strFileName);
       
      // create unique thumb for auto generated thumbs
      cachedThumb = strPath + "auto-" + strFileName;
      if (pItem->IsVideo() && !pItem->IsInternetStream() && !pItem->IsPlayList() && !CFile::Exists(cachedThumb))
      {
        if (pItem->IsStack())
        {
          CStackDirectory stack;
          CVideoThumbLoader::ExtractThumb(stack.GetFirstStackedFile(pItem->m_strPath), cachedThumb);
        }
        else
        {
          CVideoThumbLoader::ExtractThumb(pItem->m_strPath, cachedThumb);
        }
      }
  
      if (CFile::Exists(cachedThumb))
      {
        pItem->SetProperty("HasAutoThumb", "1");
        pItem->SetProperty("AutoThumbImage", cachedThumb);
        pItem->SetThumbnailImage(cachedThumb);
      }
    }
  }
  else
  {
    // look for remote thumbs
    CStdString thumb(pItem->GetThumbnailImage());
    if (!CURL::IsFileOnly(thumb) && !CUtil::IsHD(thumb))
    {      
      if(CFile::Exists(cachedThumb))
          pItem->SetThumbnailImage(cachedThumb);
      else
      {
        CPicture pic;
        if(pic.DoCreateThumbnail(thumb, cachedThumb))
          pItem->SetThumbnailImage(cachedThumb);
        else
          pItem->SetThumbnailImage("");
      }
    }  
  }

  if (!pItem->HasProperty("fanart_image"))
  {
    pItem->CacheFanart();
    
    if (pItem->GetQuickFanart().size() > 0)
    {
      if (CFile::Exists(pItem->GetCachedProgramFanart()))
        pItem->SetProperty("fanart_image",pItem->GetCachedProgramFanart());
    }
    else
    {
      if (CFile::Exists(pItem->GetCachedFanart()))
        pItem->SetProperty("fanart_image",pItem->GetCachedFanart());
    }
  }                          

  return true;
}
Пример #26
0
int CGUITextureManager::Load(const CStdString& strTextureName, DWORD dwColorKey, bool checkBundleOnly /*= false */)
{
  CStdString strPath;
  int bundle = -1;
  int size = 0;
  if (!HasTexture(strTextureName, &strPath, &bundle, &size))
    return 0;

  if (size) // we found the texture
    return size;

  // See if texture is being overridden.
  CStdString strTextureFile = strTextureName;
  CStdString strTextureOverridePath1;
  CStdString strTextureOverridePath2;
  CStdString strExt = CUtil::GetExtension(strTextureFile);
  CUtil::RemoveExtension(strTextureFile);
  
  // Check original format and JPEG.
  strTextureOverridePath1.Format("%s/media/%s%s", _P("Q:"), strTextureFile.c_str(), strExt.c_str());
  strTextureOverridePath2.Format("%s/media/%s.jpg", _P("Q:"), strTextureFile.c_str(), strExt.c_str());
  
  if (checkBundleOnly && bundle == -1)
    return 0;

  if (XFILE::CFile::Exists(strTextureOverridePath1))
    { strPath = strTextureOverridePath1; bundle = -1; }
  else if (XFILE::CFile::Exists(strTextureOverridePath2))
    { strPath = strTextureOverridePath2; bundle = -1; }
  else if (bundle == -1)
    strPath = GetTexturePath(strTextureName);
  else
    strPath = strTextureName;

  //Lock here, we will do stuff that could break rendering
  CSingleLock lock(g_graphicsContext);

#ifndef HAS_SDL
  LPDIRECT3DTEXTURE8 pTexture;
  LPDIRECT3DPALETTE8 pPal = 0;
#else
  SDL_Surface* pTexture;
  SDL_Palette* pPal = NULL;
#endif

#ifdef _DEBUG
  LARGE_INTEGER start;
  QueryPerformanceCounter(&start);
#endif

  D3DXIMAGE_INFO info;

  if (strPath.Right(4).ToLower() == ".gif")
  {
    CTextureMap* pMap;

    if (bundle >= 0)
    {
#ifndef HAS_SDL    
      LPDIRECT3DTEXTURE8* pTextures;
#else
      SDL_Surface** pTextures;
#endif
      int nLoops = 0;
      int* Delay;
#ifndef HAS_SDL
      int nImages = m_TexBundle[bundle].LoadAnim(g_graphicsContext.Get3DDevice(), strTextureName, &info, &pTextures, &pPal, nLoops, &Delay);
#else
      int nImages = m_TexBundle[bundle].LoadAnim(strTextureName, &info, &pTextures, &pPal, nLoops, &Delay);
#endif        
      if (!nImages)
      {
        CLog::Log(LOGERROR, "Texture manager unable to load bundled file: %s", strTextureName.c_str());
        return 0;
      }

      pMap = new CTextureMap(strTextureName);
      for (int iImage = 0; iImage < nImages; ++iImage)
      {
        CTexture* pclsTexture = new CTexture(pTextures[iImage], info.Width, info.Height, true, 100, pPal);
        pclsTexture->SetDelay(Delay[iImage]);
        pclsTexture->SetLoops(nLoops);
        pMap->Add(pclsTexture);
#ifndef HAS_SDL
        delete pTextures[iImage];
#else
        SDL_FreeSurface(pTextures[iImage]);
#endif
      }

      delete [] pTextures;
      delete [] Delay;
    }
    else
    {
      CAnimatedGifSet AnimatedGifSet;
      int iImages = AnimatedGifSet.LoadGIF(strPath.c_str());
      if (iImages == 0)
      {
        if (!strnicmp(strPath.c_str(), "q:\\skin", 7))
          CLog::Log(LOGERROR, "Texture manager unable to load file: %s", strPath.c_str());
        return 0;
      }
      int iWidth = AnimatedGifSet.FrameWidth;
      int iHeight = AnimatedGifSet.FrameHeight;

      int iPaletteSize = (1 << AnimatedGifSet.m_vecimg[0]->BPP);
      pMap = new CTextureMap(strTextureName);

      for (int iImage = 0; iImage < iImages; iImage++)
      {
        int w = iWidth;
        int h = iHeight;

#if defined(HAS_SDL)
        pTexture = SDL_CreateRGBSurface(SDL_HWSURFACE, w, h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
        if (pTexture)
#else
        if (D3DXCreateTexture(g_graphicsContext.Get3DDevice(), w, h, 1, 0, D3DFMT_LIN_A8R8G8B8, D3DPOOL_MANAGED, &pTexture) == D3D_OK)
#endif
        {
          CAnimatedGif* pImage = AnimatedGifSet.m_vecimg[iImage];
#ifndef HAS_SDL          
          D3DLOCKED_RECT lr;
          RECT rc = { 0, 0, pImage->Width, pImage->Height };
          if ( D3D_OK == pTexture->LockRect( 0, &lr, &rc, 0 ))
#else
          if (SDL_LockSurface(pTexture) != -1)
#endif          
          {
            COLOR *palette = AnimatedGifSet.m_vecimg[0]->Palette;
            // set the alpha values to fully opaque
            for (int i = 0; i < iPaletteSize; i++)
              palette[i].x = 0xff;
            // and set the transparent colour
            if (AnimatedGifSet.m_vecimg[0]->Transparency && AnimatedGifSet.m_vecimg[0]->Transparent >= 0)
              palette[AnimatedGifSet.m_vecimg[0]->Transparent].x = 0;
            
#ifdef HAS_SDL
            // Allocate memory for the actual pixels in the surface and set the surface
            BYTE* pixels = (BYTE*) malloc(w * h * 4);
            pTexture->pixels = pixels;
#endif            
            for (int y = 0; y < pImage->Height; y++)
            {
#ifndef HAS_SDL            
              BYTE *dest = (BYTE *)lr.pBits + y * lr.Pitch;
#else
              BYTE *dest = (BYTE *)pixels + (y * w * 4); 
#endif
              BYTE *source = (BYTE *)pImage->Raster + y * pImage->BytesPerRow;
              for (int x = 0; x < pImage->Width; x++)
              {
                COLOR col = palette[*source++];
                *dest++ = col.b;
                *dest++ = col.g;
                *dest++ = col.r;
                *dest++ = col.x;
              }
            }

#ifndef HAS_SDL
            pTexture->UnlockRect( 0 );
#else
            SDL_UnlockSurface(pTexture);
#endif            

            CTexture* pclsTexture = new CTexture(pTexture, iWidth, iHeight, false, 100, pPal);
            pclsTexture->SetDelay(pImage->Delay);
            pclsTexture->SetLoops(AnimatedGifSet.nLoops);

#ifdef HAS_SDL
            free(pixels);
#endif

#ifdef HAS_SDL_2D
            SDL_FreeSurface(pTexture);
#endif
            
            pMap->Add(pclsTexture);
          }
        }
      } // of for (int iImage=0; iImage < iImages; iImage++)
    }

#ifdef _DEBUG
    LARGE_INTEGER end, freq;
    QueryPerformanceCounter(&end);
    QueryPerformanceFrequency(&freq);
    char temp[200];
    sprintf(temp, "Load %s: %.1fms%s\n", strPath.c_str(), 1000.f * (end.QuadPart - start.QuadPart) / freq.QuadPart, (bundle >= 0) ? " (bundled)" : "");
    OutputDebugString(temp);
#endif

    m_vecTextures.push_back(pMap);
    return pMap->size();
  } // of if (strPath.Right(4).ToLower()==".gif")

  if (bundle >= 0)
  {
#ifndef HAS_SDL
    if (FAILED(m_TexBundle[bundle].LoadTexture(g_graphicsContext.Get3DDevice(), strTextureName, &info, &pTexture, &pPal)))
#else    
    if (FAILED(m_TexBundle[bundle].LoadTexture(strTextureName, &info, &pTexture, &pPal)))
#endif    
    {
      CLog::Log(LOGERROR, "Texture manager unable to load bundled file: %s", strTextureName.c_str());
      return 0;
    }
  }
  else
  {
    // normal picture
    // convert from utf8
    CStdString texturePath;
    g_charsetConverter.utf8ToStringCharset(_P(strPath), texturePath);
    
#ifndef HAS_SDL
    if ( D3DXCreateTextureFromFileEx(g_graphicsContext.Get3DDevice(), texturePath.c_str(),
                                      D3DX_DEFAULT, D3DX_DEFAULT, 1, 0, D3DFMT_LIN_A8R8G8B8, D3DPOOL_MANAGED,
                                      D3DX_FILTER_NONE , D3DX_FILTER_NONE, dwColorKey, &info, NULL, &pTexture) != D3D_OK)
    {
      if (!strnicmp(strPath.c_str(), "q:\\skin", 7))
        CLog::Log(LOGERROR, "Texture manager unable to load file: %s", strPath.c_str());
      return 0;

    }
#else
    SDL_Surface *original = IMG_Load(texturePath.c_str());
    CPicture pic;
    if (!original && !(original = pic.Load(texturePath, MAX_PICTURE_WIDTH, MAX_PICTURE_HEIGHT)))
    {
        CLog::Log(LOGERROR, "Texture manager unable to load file: %s", strPath.c_str());
        return 0;
    }
    // make sure the texture format is correct
    SDL_PixelFormat format;
    format.palette = 0; format.colorkey = 0; format.alpha = 0;
    format.BitsPerPixel = 32; format.BytesPerPixel = 4;
    format.Amask = 0xff000000; format.Ashift = 24;
    format.Rmask = 0x00ff0000; format.Rshift = 16;
    format.Gmask = 0x0000ff00; format.Gshift = 8;
    format.Bmask = 0x000000ff; format.Bshift = 0;
#ifdef HAS_SDL_OPENGL
    pTexture = SDL_ConvertSurface(original, &format, SDL_SWSURFACE);
#else
    pTexture = SDL_ConvertSurface(original, &format, SDL_HWSURFACE);
#endif
    SDL_FreeSurface(original);
    if (!pTexture)
    {
      CLog::Log(LOGERROR, "Texture manager unable to load file: %s", strPath.c_str());
      return 0;
    }
    info.Width = pTexture->w;
    info.Height = pTexture->h;
#endif
  }

  CTextureMap* pMap = new CTextureMap(strTextureName);
  CTexture* pclsTexture = new CTexture(pTexture, info.Width, info.Height, bundle >= 0, 100, pPal);
  pMap->Add(pclsTexture);
  m_vecTextures.push_back(pMap);

#ifdef HAS_SDL_OPENGL
  SDL_FreeSurface(pTexture);
#endif    

#ifdef _DEBUG
  LARGE_INTEGER end, freq;
  QueryPerformanceCounter(&end);
  QueryPerformanceFrequency(&freq);
  char temp[200];
  sprintf(temp, "Load %s: %.1fms%s\n", strPath.c_str(), 1000.f * (end.QuadPart - start.QuadPart) / freq.QuadPart, (bundle >= 0) ? " (bundled)" : "");
  OutputDebugString(temp);
#endif

  return 1;
}
Пример #27
0
// Get Thumb from user choice.
// Options are:
// 1.  Current thumb
// 2.  IMDb thumb
// 3.  Local thumb
// 4.  No thumb (if no Local thumb is available)
void CGUIWindowVideoInfo::OnGetThumb()
{
  CFileItemList items;

  // Grab the thumbnails from the web
  CStdString strPath;
  CUtil::AddFileToFolder(g_advancedSettings.m_cachePath,"imdbthumbs",strPath);
  CUtil::WipeDir(_P(strPath));
  DIRECTORY::CDirectory::Create(strPath);
  int i=1;
  for (std::vector<CScraperUrl::SUrlEntry>::iterator iter=m_movieItem->GetVideoInfoTag()->m_strPictureURL.m_url.begin();iter != m_movieItem->GetVideoInfoTag()->m_strPictureURL.m_url.end();++iter)
  {
    if (iter->m_type == CScraperUrl::URL_TYPE_SEASON)
      continue;
    CStdString thumbFromWeb;
    CStdString strLabel;
    strLabel.Format("imdbthumb%i.jpg",i);
    CUtil::AddFileToFolder(strPath, strLabel, thumbFromWeb);
    if (CScraperUrl::DownloadThumbnail(thumbFromWeb,*iter))
    {
      CStdString strItemPath;
      strItemPath.Format("thumb://IMDb%i",i++);
      CFileItem *item = new CFileItem(strItemPath, false);
      item->SetThumbnailImage(thumbFromWeb);
      CStdString strLabel;
      item->SetLabel(g_localizeStrings.Get(20015));
      items.Add(item);
    }
  }
  if (CFile::Exists(m_movieItem->GetThumbnailImage()))
  {
    CFileItem *item = new CFileItem("thumb://Current", false);
    item->SetThumbnailImage(m_movieItem->GetThumbnailImage());
    item->SetLabel(g_localizeStrings.Get(20016));
    items.Add(item);
  }

  CStdString cachedLocalThumb;
  CStdString localThumb(m_movieItem->GetUserVideoThumb());
  if (CFile::Exists(localThumb))
  {
    CUtil::AddFileToFolder(g_advancedSettings.m_cachePath, "localthumb.jpg", cachedLocalThumb);
    CPicture pic;
    pic.DoCreateThumbnail(localThumb, cachedLocalThumb);
    CFileItem *item = new CFileItem("thumb://Local", false);
    item->SetThumbnailImage(cachedLocalThumb);
    item->SetLabel(g_localizeStrings.Get(20017));
    items.Add(item);
  }
  else
  { // no local thumb exists, so we are just using the IMDb thumb or cached thumb
    // which is probably the IMDb thumb.  These could be wrong, so allow the user
    // to delete the incorrect thumb
    CFileItem *item = new CFileItem("thumb://None", false);
    item->SetThumbnailImage("defaultVideoBig.png");
    item->SetLabel(g_localizeStrings.Get(20018));
    items.Add(item);
  }

  CStdString result;
  if (!CGUIDialogFileBrowser::ShowAndGetImage(items, g_settings.m_videoSources, g_localizeStrings.Get(20019), result))
    return;   // user cancelled

  if (result == "thumb://Current")
    return;   // user chose the one they have

  // delete the thumbnail if that's what the user wants, else overwrite with the
  // new thumbnail
  CFileItem item(*m_movieItem->GetVideoInfoTag());
  CStdString cachedThumb(item.GetCachedVideoThumb());

  if (result.Mid(0,12) == "thumb://IMDb")
  {
    CStdString strFile;
    CUtil::AddFileToFolder(strPath,"imdbthumb"+result.Mid(12)+".jpg",strFile);
    if (CFile::Exists(strFile))
      CFile::Cache(strFile, cachedThumb);
    else
      result = "thumb://None";
  }
  else if (result == "thumb://Local")
    CFile::Cache(cachedLocalThumb, cachedThumb);
  else if (CFile::Exists(result))
  {
    CPicture pic;
    pic.DoCreateThumbnail(result, cachedThumb);
  }
  else 
    result = "thumb://None";

  if (result == "thumb://None")
  { // cache the default thumb
    CPicture pic;
    pic.CacheSkinImage("defaultVideoBig.png", cachedThumb);
  }

  CUtil::DeleteVideoDatabaseDirectoryCache(); // to get them new thumbs to show
  m_movieItem->SetThumbnailImage(cachedThumb);

  // tell our GUI to completely reload all controls (as some of them
  // are likely to have had this image in use so will need refreshing)
  CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS);
  g_graphicsContext.SendMessage(msg);
  // Update our screen
  Update();
}
Пример #28
0
// Allow user to select a Fanart
void CGUIWindowVideoInfo::OnGetFanart()
{
  CFileItemList items;

  // Grab the thumbnails from the web
  CStdString strPath;
  CUtil::AddFileToFolder(g_advancedSettings.m_cachePath,"fanartthumbs",strPath);
  CUtil::WipeDir(strPath);
  DIRECTORY::CDirectory::Create(strPath);
  for (unsigned int i = 0; i < m_movieItem->GetVideoInfoTag()->m_fanart.GetNumFanarts(); i++)
  {
    CStdString thumbFromWeb;
    CStdString strLabel;
    strLabel.Format("fanart_thumb_%i.jpg", i);
    CUtil::AddFileToFolder(strPath, strLabel, thumbFromWeb);
    if (m_movieItem->GetVideoInfoTag()->m_fanart.DownloadThumb(i, thumbFromWeb))
    {
      CStdString strItemPath;
      strItemPath.Format("thumb://FANART_%i",i);
      CFileItem *item = new CFileItem(strItemPath, false);
      item->SetThumbnailImage(thumbFromWeb);
      CStdString strLabel;
      item->SetLabel(g_localizeStrings.Get(20015));
      items.Add(item);
    }
    else
      CLog::Log(LOGDEBUG, "Unable to download fanart thumb #%d", i);
  }

  CFileItem *itemNone = new CFileItem("thumb://None", false);
  itemNone->SetThumbnailImage("defaultVideoBig.png");
  itemNone->SetLabel(g_localizeStrings.Get(20018));
  items.Add(itemNone);

  CStdString result;
  if (!CGUIDialogFileBrowser::ShowAndGetImage(items, g_settings.m_videoSources, g_localizeStrings.Get(20019), result))
    return;   // user cancelled

  // delete the thumbnail if that's what the user wants, else overwrite with the
  // new thumbnail
  CFileItem item(*m_movieItem->GetVideoInfoTag());
  CStdString cachedThumb(item.GetCachedVideoFanart());

  if (result.Mid(0,15) == "thumb://FANART_")
  {
    CStdString strFile;
    CUtil::AddFileToFolder(strPath,"fanart_thumb_"+result.Mid(15)+".jpg",strFile);
    int iFanart = atoi(result.Mid(15).c_str());
    if (CFile::Exists(strFile))
    {
      // set new primary fanart, and update our database accordingly
      m_movieItem->GetVideoInfoTag()->m_fanart.SetPrimaryFanart(iFanart);
      m_database.SetDetailsForTvShow(m_movieItem->m_strPath, *m_movieItem->GetVideoInfoTag());

      // download the fullres fanart image.  TODO: FANART - this could take some time, so should probably be backgrounded
      m_movieItem->GetVideoInfoTag()->m_fanart.DownloadImage(cachedThumb);
    }
    else
      result = "thumb://None";
  }
  else if (CFile::Exists(result))
  { // local file
    CPicture pic;
    pic.CacheImage(result, cachedThumb);
  }
  else
    result = "thumb://None";

  if (result == "thumb://None")
  { // remove the cached art
    if (CFile::Exists(cachedThumb))
      CFile::Delete(cachedThumb);
  }

  CUtil::DeleteVideoDatabaseDirectoryCache(); // to get them new thumbs to show

  // tell our GUI to completely reload all controls (as some of them
  // are likely to have had this image in use so will need refreshing)
  CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS);
  g_graphicsContext.SendMessage(msg);
  // Update our screen
  Update();
}
Пример #29
0
// TODO: Currently no support for "embedded thumb" as there is no easy way to grab it
//       without sending a file that has this as it's album to this class
void CGUIDialogSongInfo::OnGetThumb()
{
  CFileItemList items;

  
  // Grab the thumbnail from the web
  CStdString thumbFromWeb;
  /*
  CUtil::AddFileToFolder(g_advancedSettings.m_cachePath, "allmusicThumb.jpg", thumbFromWeb);
  if (DownloadThumbnail(thumbFromWeb))
  {
    CFileItemPtr item(new CFileItem("thumb://allmusic.com", false));
    item->SetThumbnailImage(thumbFromWeb);
    item->SetLabel(g_localizeStrings.Get(20055));
    items.Add(item);
  }*/

  // Current thumb
  if (CFile::Exists(m_song->GetThumbnailImage()))
  {
    CFileItemPtr item(new CFileItem("thumb://Current", false));
    item->SetThumbnailImage(m_song->GetThumbnailImage());
    item->SetLabel(g_localizeStrings.Get(20016));
    items.Add(item);
  }

  // local thumb
  CStdString cachedLocalThumb;
  CStdString localThumb(m_song->GetUserMusicThumb(true));
  if (m_song->IsMusicDb())
  {
    CFileItem item(m_song->GetMusicInfoTag()->GetURL(), false);
    localThumb = item.GetUserMusicThumb(true);
  }
  if (CFile::Exists(localThumb))
  {
    CUtil::AddFileToFolder(g_advancedSettings.m_cachePath, "localthumb.jpg", cachedLocalThumb);
    CPicture pic;
    if (pic.DoCreateThumbnail(localThumb, cachedLocalThumb))
    {
      CFileItemPtr item(new CFileItem("thumb://Local", false));
      item->SetThumbnailImage(cachedLocalThumb);
      item->SetLabel(g_localizeStrings.Get(20017));
      items.Add(item);
    }
  }
  else
  { // no local thumb exists, so we are just using the allmusic.com thumb or cached thumb
    // which is probably the allmusic.com thumb.  These could be wrong, so allow the user
    // to delete the incorrect thumb
    CFileItemPtr item(new CFileItem("thumb://None", false));
    item->SetThumbnailImage("defaultAlbumCover.png");
    item->SetLabel(g_localizeStrings.Get(20018));
    items.Add(item);
  }

  CStdString result;
  if (!CGUIDialogFileBrowser::ShowAndGetImage(items, g_settings.m_musicSources, g_localizeStrings.Get(1030), result))
    return;   // user cancelled

  if (result == "thumb://Current")
    return;   // user chose the one they have

  // delete the thumbnail if that's what the user wants, else overwrite with the
  // new thumbnail

  CStdString cachedThumb(CUtil::GetCachedAlbumThumb(m_song->GetMusicInfoTag()->GetAlbum(), m_song->GetMusicInfoTag()->GetArtist()));

  if (result == "thumb://None")
  { // cache the default thumb
    CPicture pic;
    pic.CacheSkinImage("defaultAlbumCover.png", cachedThumb);
  }
  else if (result == "thumb://allmusic.com")
    CFile::Cache(thumbFromWeb, cachedThumb);
  else if (result == "thumb://Local")
    CFile::Cache(cachedLocalThumb, cachedThumb);
  else if (CFile::Exists(result))
  {
    CPicture pic;
    pic.DoCreateThumbnail(result, cachedThumb);
  }

  m_song->SetThumbnailImage(cachedThumb);

  // tell our GUI to completely reload all controls (as some of them
  // are likely to have had this image in use so will need refreshing)
  CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS);
  g_graphicsContext.SendMessage(msg);

//  m_hasUpdatedThumb = true;
}
Пример #30
0
CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect & pos, CBattleInterface * _owner)
: owner(_owner)
{
	OBJ_CONSTRUCTION_CAPTURING_ALL;
	this->pos = pos;
	CPicture * bg = new CPicture("CPRESULT");
	bg->colorize(owner->curInt->playerID);

	exit = new CAdventureMapButton ("", "", boost::bind(&CBattleResultWindow::bExitf,this), 384, 505, "iok6432.def", SDLK_RETURN);
	exit->borderColor = Colors::METALLIC_GOLD;
	exit->borderEnabled = true;

	if(br.winner==0) //attacker won
	{
		new CLabel( 59, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410]);
		new CLabel(408, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411]);
	}
	else //if(br.winner==1)
	{
		new CLabel( 59, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411]);
		new CLabel(412, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410]);
	}

	new CLabel(232, 302, FONT_BIG, CENTER, Colors::YELLOW,  CGI->generaltexth->allTexts[407]);
	new CLabel(232, 332, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[408]);
	new CLabel(232, 428, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[409]);

	std::string attackerName, defenderName;

	if(owner->attackingHeroInstance) //a hero attacked
	{
		new CAnimImage("PortraitsLarge", owner->attackingHeroInstance->portrait, 0, 21, 38);
		//setting attackerName
		attackerName = owner->attackingHeroInstance->name;
	}
	else //a monster attacked
	{
		int bestMonsterID = -1;
		ui32 bestPower = 0;
		for(TSlots::const_iterator it = owner->army1->Slots().begin(); it!=owner->army1->Slots().end(); ++it)
		{
			if(it->second->type->AIValue > bestPower)
			{
				bestPower = it->second->type->AIValue;
				bestMonsterID = it->second->type->idNumber;
			}
		}
		new CAnimImage("TWCRPORT", bestMonsterID+2, 0, 21, 38);
		//setting attackerName
		attackerName =  CGI->creh->creatures[bestMonsterID]->namePl;
	}
	if(owner->defendingHeroInstance) //a hero defended
	{
		new CAnimImage("PortraitsLarge", owner->defendingHeroInstance->portrait, 0, 392, 38);
		//setting defenderName
		defenderName = owner->defendingHeroInstance->name;
	}
	else //a monster defended
	{
		int bestMonsterID = -1;
		ui32 bestPower = 0;
		for(TSlots::const_iterator it = owner->army2->Slots().begin(); it!=owner->army2->Slots().end(); ++it)
		{
			if( it->second->type->AIValue > bestPower)
			{
				bestPower = it->second->type->AIValue;
				bestMonsterID = it->second->type->idNumber;
			}
		}
		new CAnimImage("TWCRPORT", CGI->creh->creatures[bestMonsterID]->iconIndex, 0, 392, 38);
		//setting defenderName
		defenderName =  CGI->creh->creatures[bestMonsterID]->namePl;
	}

	//printing attacker and defender's names
	new CLabel( 89, 37, FONT_SMALL, TOPLEFT, Colors::WHITE, attackerName);

	new CLabel( 381, 53, FONT_SMALL, BOTTOMRIGHT, Colors::WHITE, defenderName);

	//printing casualities
	for(int step = 0; step < 2; ++step)
	{
		if(br.casualties[step].size()==0)
		{
			new CLabel( 235, 360 + 97*step, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[523]);
		}
		else
		{
			int xPos = 235 - (br.casualties[step].size()*32 + (br.casualties[step].size() - 1)*10)/2; //increment by 42 with each picture
			int yPos = 344 + step*97;
			for(std::map<ui32,si32>::const_iterator it=br.casualties[step].begin(); it!=br.casualties[step].end(); ++it)
			{
				new CAnimImage("CPRSMALL", CGI->creh->creatures[it->first]->iconIndex, 0, xPos, yPos);
				std::ostringstream amount;
				amount<<it->second;
				new CLabel( xPos+16, yPos + 42, FONT_SMALL, CENTER, Colors::WHITE, amount.str());
				xPos += 42;
			}
		}
	}
	//printing result description
	bool weAreAttacker = (owner->curInt->playerID == owner->attackingHeroInstance->tempOwner);
	if((br.winner == 0 && weAreAttacker) || (br.winner == 1 && !weAreAttacker)) //we've won
	{
		int text=-1;
		switch(br.result)
		{
		case BattleResult::NORMAL: text = 304; break;
		case BattleResult::ESCAPE: text = 303; break;
		case BattleResult::SURRENDER: text = 302; break;
		}

		CCS->musich->playMusic("Music/Win Battle", false);
		CCS->videoh->open("WIN3.BIK");
		std::string str = CGI->generaltexth->allTexts[text];

		const CGHeroInstance * ourHero = weAreAttacker? owner->attackingHeroInstance : owner->defendingHeroInstance;
		if (ourHero)
		{
			str += CGI->generaltexth->allTexts[305];
			boost::algorithm::replace_first(str,"%s",ourHero->name);
			boost::algorithm::replace_first(str,"%d",boost::lexical_cast<std::string>(br.exp[weAreAttacker?0:1]));
		}
		
		new CTextBox(str, Rect(69, 203, 330, 68), 0, FONT_SMALL, CENTER, Colors::WHITE);
	}
	else // we lose
	{
		switch(br.result)
		{
		case BattleResult::NORMAL:
			{
				CCS->musich->playMusic("Music/LoseCombat", false);
				CCS->videoh->open("LBSTART.BIK");
				new CLabel(235, 235, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[311]);
				break;
			}
		case BattleResult::ESCAPE: //flee
			{
				CCS->musich->playMusic("Music/Retreat Battle", false);
				CCS->videoh->open("RTSTART.BIK");
				new CLabel(235, 235, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[310]);
				break;
			}
		case BattleResult::SURRENDER:
			{
				CCS->musich->playMusic("Music/Surrender Battle", false);
				CCS->videoh->open("SURRENDER.BIK");
				new CLabel(235, 235, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[309]);
				break;
			}
		}
	}
}