private Texture2D(ImageFormatType imageFormat, byte[] imageBytes, uint resourceSetNo, string textureName, string samplerName)
        {
            if (null == textureName || null == samplerName)
            {
                throw new ArgumentException("Must provide valid texture and sampler name");
            }

            ResourceSetNo = resourceSetNo;
            TextureName   = textureName;
            SamplerName   = samplerName;
            ImageFormat   = imageFormat;
            ImageBytes    = imageBytes;

            if (null != ImageBytes)
            {
                var texProcessor = new ImageSharpProcessor();
                using (var stream = new MemoryStream(ImageBytes))
                {
                    switch (ImageFormat)
                    {
                    case ImageFormatType.Jpeg:
                        ProcessedTexture = texProcessor.ProcessT(stream, "jpg");
                        break;

                    case ImageFormatType.Png:
                        ProcessedTexture = texProcessor.ProcessT(stream, "png");
                        break;

                    default:
                        throw new InvalidEnumArgumentException("Unknown type");
                    }
                }
            }
        }
示例#2
0
        public void GetSizeStream() {
            using (var file = File.OpenRead("../../../Assets/HLD_Screenshot_01_mech_1080.png")) {
                var processor = new ImageSharpProcessor();

                processor.GetSize(file, out var width, out var height);

                Assert.Equal(1920, width);
                Assert.Equal(1080, height);
            }
        }
示例#3
0
        public T LoadFileAsset <T>(string name)
        {
            var isProcessor = new ImageSharpProcessor();

            object processedAsset;

            using (FileStream fs = File.OpenRead(name))
            {
                processedAsset = isProcessor.Process(fs, ".png");
            }

            return((T)processedAsset);
        }
示例#4
0
        public void GetSizeBytes() {
            using (var file = File.OpenRead("../../../Assets/HLD_Screenshot_01_mech_1080.png")) {
                using (var reader = new BinaryReader(file)) {
                    var bytes = reader.ReadBytes((int) file.Length);

                    var processor = new ImageSharpProcessor();

                    processor.GetSize(bytes, out var width, out var height);

                    Assert.Equal(1920, width);
                    Assert.Equal(1080, height);
                }
            }
        }
示例#5
0
        public void CropScale() {
            using (var file = File.OpenRead("../../../Assets/HLD_Screenshot_01_mech_1080.png")) {
                var processor = new ImageSharpProcessor();

                using (var outStream = new MemoryStream()) {
                    processor.CropScale(file, outStream, 640, 480);

                    outStream.Position = 0;

                    processor.GetSize(outStream, out var width, out var height);

                    Assert.Equal(640, width);
                    Assert.Equal(480, height);
                }
            }
        }
示例#6
0
        static void Main(string[] args)
        {
            Parser.Default.ParseArguments <IndexerArguments>(args)
            .WithParsed(o =>
            {
                var config = new ComicViewerConfiguration()
                {
                    ComicRepositoryPath = o.IndexPath,
                    DatabasePath        = o.Database,
                    ThumbnailHeight     = new System.Collections.Generic.Dictionary <string, int>
                    {
                        { "small", 80 },
                        { "large", 300 }
                    }
                };
                var context      = new ComicBookContext(config, new Microsoft.EntityFrameworkCore.DbContextOptions <ComicBookContext>());
                var imgProcessor = new ImageSharpProcessor(config);
                var factory      = new ComicBookFactory(imgProcessor, new IComicInterigator[] {
                    new IdInterigator(),
                    new ImageInterigator(config, context, imgProcessor),
                    new VolumeInterigator(),
                    new IssueInterigator(),
                    new DateInterigator(),
                    new PublisherInterigator(),
                    new NameInterigator(),
                    new TitleInterigator()
                });
                var resolver = new StoreComicBookResolver(config, context);
                Console.WriteLine("Starting Index");
                var indexer = new StoreIndexer(config, factory, resolver).Run();
            })
            .WithNotParsed((errs) => { Console.WriteLine("Could not parse arguments"); });

#if DEBUG
            Console.WriteLine("Press any key to close.");
            Console.ReadKey();
#endif
        }