void saveThumb(Thumb thumbObject, string savePathWithoutExt, bool isCover, bool shrink) { if (shrink) { if (maxThumbDimension < 0 || (thumbObject.Image.Width <= maxThumbDimension && thumbObject.Image.Height <= maxThumbDimension)) maxThumbDimension = 0; } string newPath; string extension; if (!isCover && maxThumbDimension == 0 && isValidThumbPath(thumbObject.Path, out extension)) { newPath = savePathWithoutExt + extension; if (!copyThumbFromFile(thumbObject.Path, newPath)) return; } else { newPath = savePathWithoutExt + ".png"; double aspectRatio = isCover ? thumbAspect : 0; if (!copyThumbFromImage(thumbObject.Image, aspectRatio, maxThumbDimension, newPath)) return; } RemoveAlternateThumb(newPath); thumbObject.Path = newPath; }
/// <summary> /// Initialises a new ThumbGroup with the thumbs of the specified parent /// </summary> /// <param name="parent">An Emulator or Game</param> public ThumbGroup(ThumbItem parent) { if (parent == null) throw new ArgumentException("The parent item cannot be null", "parent"); Options options = EmulatorsCore.Options; options.EnterReadLock(); bool doResize = options.ResizeGameart; maxThumbDimension = EmulatorsCore.Options.MaxImageDimensions; string imageDirectory = options.ImageDirectory; options.ExitReadLock(); string thumbFolder = parent.ThumbFolder; if (doResize) thumbAspect = parent.AspectRatio; parentItem = parent; lock (parent.SyncRoot) { if (parent.Id != null) thumbPath = string.Format(@"{0}\{1}\{2}\{3}\", imageDirectory, THUMB_DIR_NAME, thumbFolder, parent.Id); } //init Thumbs logo = new Thumb(ThumbType.Logo); frontCover = new Thumb(ThumbType.FrontCover); backCover = new Thumb(ThumbType.BackCover); titleScreen = new Thumb(ThumbType.TitleScreen); inGame = new Thumb(ThumbType.InGameScreen); fanart = new Thumb(ThumbType.Fanart); //load the paths/images loadThumbs(); }