Generate Covers for songs

This commit is contained in:
Flamefire committed 2014-10-23 17:05:57 +02:00
1 parent 0a48c6b74b
commit fe07a2f926
6 files changed
+27 -18

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@
</Info> </Info>
<!--Cover definitions when a category is missing a cover--> <!--Cover definitions when a category is missing a cover-->
<CoverGenerator1> <CoverGenerator1>
<!--Possible types are: Default, Artist, Letter, Edition, Genre, Language, Year, Decade, Date --> <!--Possible types are: Default, Song, Artist, Letter, Edition, Genre, Language, Year, Decade, Date -->
<Type>Default</Type> <Type>Default</Type>
<Text> <Text>
<!--<Text>: Text to be shown, %TEXT% will be replace by the category name--> <!--<Text>: Text to be shown, %TEXT% will be replace by the category name-->
+5
View File
@@ -871,6 +871,11 @@ namespace Vocaluxe.Base
{ {
return CCover.NoCover; return CCover.NoCover;
} }
public CTextureRef GenerateCover(string text, ECoverGeneratorType type, CSong firstSong)
{
return CCover.GenerateCover(text, type, firstSong);
}
} }
class CBdataBase : IDataBase class CBdataBase : IDataBase
+16 -13
View File
@@ -833,23 +833,26 @@ namespace Vocaluxe.Lib.Draw
public CTextureRef CopyTexture(CTextureRef textureRef) public CTextureRef CopyTexture(CTextureRef textureRef)
{ {
_EnsureMainThread(); // Lock to make sure the texture is not disposed while we are in this method
TTextureType texture; lock (_Textures)
if (!_GetTexture(textureRef, out texture, false))
return null;
// If bitmap is not yet loaded, wait for it
if (!String.IsNullOrEmpty(texture.TexturePath))
{ {
Task<Size> loader; TTextureType texture;
lock (_BitmapsLoading) if (!_GetTexture(textureRef, out texture, false))
return null;
// If bitmap is not yet loaded, wait for it
if (!String.IsNullOrEmpty(texture.TexturePath))
{ {
_BitmapsLoading.TryGetValue(texture.TexturePath, out loader); Task<Size> loader;
lock (_BitmapsLoading)
{
_BitmapsLoading.TryGetValue(texture.TexturePath, out loader);
}
if (loader != null)
textureRef.OrigSize = loader.Result;
} }
if (loader != null) Debug.Assert(textureRef.OrigSize.Width > 0);
textureRef.OrigSize = loader.Result; return _GetTextureReference(textureRef.OrigSize, texture);
} }
Debug.Assert(textureRef.OrigSize.Width > 0);
return _GetTextureReference(textureRef.OrigSize, texture);
} }
/// <summary> /// <summary>
+1
View File
@@ -283,6 +283,7 @@ namespace VocaluxeLib
public interface ICover public interface ICover
{ {
CTextureRef GetNoCover(); CTextureRef GetNoCover();
CTextureRef GenerateCover(string text, ECoverGeneratorType type, CSong firstSong);
} }
public interface IDataBase public interface IDataBase
+3 -4
View File
@@ -314,11 +314,10 @@ namespace VocaluxeLib.Songs
return; return;
if (CoverFileName != "") if (CoverFileName != "")
{ {
if (!CBase.DataBase.GetCover(Path.Combine(Folder, CoverFileName), ref _CoverTextureSmall, CBase.Config.GetCoverSize())) if (CBase.DataBase.GetCover(Path.Combine(Folder, CoverFileName), ref _CoverTextureSmall, CBase.Config.GetCoverSize()))
_CoverTextureSmall = CBase.Cover.GetNoCover(); return;
} }
else _CoverTextureSmall = CBase.Cover.GenerateCover(Title, ECoverGeneratorType.Song, null);
_CoverTextureSmall = CBase.Cover.GetNoCover();
} }
private void _CheckFiles() private void _CheckFiles()
+1
View File
@@ -29,6 +29,7 @@ namespace VocaluxeLib
public enum ECoverGeneratorType public enum ECoverGeneratorType
{ {
Default, Default,
Song,
Folder, Folder,
Artist, Artist,
Letter, Letter,