Esempio n. 1
0
        public void Add(string name, string sourceFile, int dataOffset, int dataLength, IEnumerable <ImageSliceInfo> imageSlices)
        {
            if (!Items.TryGetValue(name, out var catalogItem))
            {
                catalogItem = new HdAssetCatalogItem(name);
                Items.Add(name, catalogItem);
            }

            foreach (var imageSlice in imageSlices)
            {
                catalogItem.AddImage(sourceFile, dataOffset, dataLength, imageSlice);
            }
        }
Esempio n. 2
0
        internal static void LoadFrames(HdAssetCatalogItem hdAssetCatalogItem, Action frameLoadedCallback)
        {
            var cache = new Dictionary <string, MagickImage>();

            foreach (var frame in hdAssetCatalogItem.HdPakFrames.Values)
            {
                var sheet = GetSpriteSheet(cache, frame.SourceFilePath, frame.SheetDataOffset, frame.SheetCompressedLength);

                var frameImage = (MagickImage)sheet.Clone(frame.Metadata.X, frame.Metadata.Y, frame.Metadata.Width, frame.Metadata.Height);
                frameImage.Rotate(90.0 * frame.Metadata.Rotation);

                var scalingPercentage = new Percentage(200.0 / frame.Metadata.Scaling);
                frameImage.AdaptiveResize(new MagickGeometry(scalingPercentage, scalingPercentage));

                frame.Image = frameImage;

                frameLoadedCallback();
            }

            foreach (var cacheItem in cache.Values)
            {
                cacheItem.Dispose();
            }
        }