Added cover page

This commit is contained in:
Marco Gavelli
2018-07-16 16:29:46 +02:00
parent 3e251c35ec
commit d407c971ee
2 changed files with 41 additions and 18 deletions

View File

@@ -38,10 +38,20 @@ namespace QuickLook.Plugin.EpubViewer
protected override async void OnImageLoad(HtmlImageLoadEventArgs args)
{
string imageFilePath = GetFullPath(ChapterRef.ContentFileName, args.Src);
if (EpubBook.Content.Images.TryGetValue(imageFilePath, out EpubByteContentFileRef imageContent))
string imageFilePath = ChapterRef != null ? GetFullPath(ChapterRef.ContentFileName, args.Src) : null;
byte[] imageBytes = null;
if (args.Src == "COVER")
{
using (MemoryStream imageStream = new MemoryStream(await imageContent.ReadContentAsBytesAsync()))
imageBytes = await EpubBook.ReadCoverAsync();
}
else if (EpubBook.Content.Images.TryGetValue(imageFilePath, out EpubByteContentFileRef imageContent))
{
imageBytes = await imageContent.ReadContentAsBytesAsync();
}
if (imageBytes != null)
{
using (MemoryStream imageStream = new MemoryStream(imageBytes))
{
try
{
@@ -58,7 +68,7 @@ namespace QuickLook.Plugin.EpubViewer
{
Debug.WriteLine($"Failed to load image: {args.Src}");
}
}
}
}
}