static void CreateThumbnailForDoc(Doc doc, DisplayState& ds) { CrashIf(!doc.AsEpub() && !doc.AsFb2() && !doc.AsMobi()); if (!ShouldSaveThumbnail(ds)) return; // if there is cover image, we use it to generate thumbnail by scaling // image width to thumbnail dx, scaling height proportionally and using // as much of it as fits in thumbnail dy RenderedBitmap *bmp = ThumbFromCoverPage(doc); if (!bmp) { // no cover image so generate thumbnail from first page SizeI pageSize(THUMBNAIL_DX * 3, THUMBNAIL_DY * 3); SizeI dstSize(THUMBNAIL_DX, THUMBNAIL_DY); bmp = RenderFirstDocPageToBitmap(doc, pageSize, dstSize, 10); } SaveThumbnailForFile(doc.GetFilePath(), bmp); }