public void AddImage(ImageOnStorage image) { var item = new ManifestItemV3 { HRef = image.PathInEPUB.GetRelativePath(DefaultInternalPaths.ContentFilePath, _flatStructure), ID = image.ID, MediaType = EPUBImage.ConvertImageTypeToMediaType(image.ImageType) }; if (CoverId == image.ID) { item.CoverImage = true; } _manifest.Add(item); }
/// <summary> /// Converts list of FB2 images to EPub images /// </summary> /// <param name="fb2Images"></param> /// <param name="epubImages"></param> public void ConvertFb2ToEpubImages(Dictionary <string, BinaryItem> fb2Images, Dictionary <string, EPUBImage> epubImages) { epubImages.Clear(); foreach (var item in fb2Images) { var image = new EPUBImage { ID = item.Value.Id }; Logger.Log.DebugFormat("Image ID : {0}", image.ID); image.ImageData = item.Value.BinaryData; if (item.Value.ContentType == ContentTypeEnum.ContentTypeJpeg) { image.ImageType = EPUBImageTypeEnum.ImageJPG; } else if (item.Value.ContentType == ContentTypeEnum.ContentTypePng) { image.ImageType = EPUBImageTypeEnum.ImagePNG; } else if (item.Value.ContentType == ContentTypeEnum.ContentTypeGif) { image.ImageType = EPUBImageTypeEnum.ImageGIF; } else { Logger.Log.ErrorFormat("Unknown image type {0}", item.Value.ContentType); continue; } if (IsImageIdUsed(image.ID)) // only if image registered as used { try { if (RemoveAlpha && (image.ImageType == EPUBImageTypeEnum.ImagePNG)) { image.ImageData = GetPNGWithoutAlpha(image.ImageData); } epubImages.Add(string.Format("#{0}", image.ID), image); } catch (Exception ex) { RemoveBinaryImageId(image.ID); Logger.Log.ErrorFormat("Error reading PNG file {0}", ex); } } } }
public ImageOnStorage(EPUBImage eImage) { _id = eImage.ID; _imageType = eImage.ImageType; }
public ImageOnStorage(EPUBImage eImage) { _id = eImage.ID; _imageType = eImage.ImageType; }
public void AddImage(ImageOnStorage image) { _manifest.Add(new ManifestItemV2 { HRef = image.PathInEPUB.GetRelativePath(DefaultInternalPaths.ContentFilePath, _flatStructure), ID = image.ID, MediaType = EPUBImage.ConvertImageTypeToMediaType(image.ImageType) }); }