コード例 #1
0
    static IReadOnlyTexture <byte> Read(AssetId id, uint[] palette, IList <Image <Rgba32> > images)
    {
        int totalWidth    = images.Max(x => x.Width);
        int totalHeight   = images.Sum(x => x.Height);
        var pixels        = new byte[totalWidth * totalHeight];
        var frames        = new List <Region>();
        int currentY      = 0;
        var quantizeCache = new Dictionary <uint, byte>();

        for (int i = 0; i < images.Count; i++)
        {
            Image <Rgba32> image = images[i];
            if (!image.TryGetSinglePixelSpan(out Span <Rgba32> rgbaSpan))
            {
                throw new InvalidOperationException("Could not retrieve single span from Image");
            }

            frames.Add(new Region(0, currentY, image.Width, image.Height, totalWidth, totalHeight, 0));
            var uintSpan = MemoryMarshal.Cast <Rgba32, uint>(rgbaSpan);
            var from     = new ReadOnlyImageBuffer <uint>(image.Width, image.Height, image.Width, uintSpan);
            var byteSpan = pixels.AsSpan(currentY * totalWidth, totalWidth * (image.Height - 1) + image.Width);
            var to       = new ImageBuffer <byte>(image.Width, image.Height, totalWidth, byteSpan);
            BlitUtil.Blit32To8(from, to, palette, quantizeCache);

            currentY += image.Height;
        }

        return(new SimpleTexture <byte>(id, id.ToString(), totalWidth, totalHeight, pixels, frames));
    }
コード例 #2
0
ファイル: Asset.cs プロジェクト: DubovskayaKate/iTechArt_Task
 public override string ToString()
 {
     return($"| {AssetId.ToString().PadLeft(6, ' ')} " +
            $"| {Name.PadLeft(15, ' ')} " +
            $"| {Balance.ToString().PadLeft(6, ' ')} " +
            $"| {(User == null ? 0 : User.UserId)}|");
 }
コード例 #3
0
        /// <inheritdoc />
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            AssetId assetId = value as AssetId;

            if (assetId != null)
            {
                writer.WriteValue(assetId.ToString(Network));
            }
        }
コード例 #4
0
        public override PaymentUrlBuilder GenerateBIP21(string cryptoInfoAddress, Money cryptoInfoDue)
        {
            //precision 0: 10 = 0.00000010
            //precision 2: 10 = 0.00001000
            //precision 8: 10 = 10
            var money   = cryptoInfoDue is null ? null : new Money(cryptoInfoDue.ToDecimal(MoneyUnit.BTC) / decimal.Parse("1".PadRight(1 + 8 - Divisibility, '0')), MoneyUnit.BTC);
            var builder = base.GenerateBIP21(cryptoInfoAddress, money);

            builder.QueryParams.Add("assetid", AssetId.ToString());
            return(builder);
        }
コード例 #5
0
        public void ToString_ShouldReturn_Guid()
        {
            // Arrange
            var assetId = new AssetId(new Guid("7BE324F2-25A0-4C85-9B85-069B16B0B84F"));

            // Act
            var actual = assetId.ToString();

            // Assert
            Assert.That(actual, Is.EqualTo("7BE324F2-25A0-4C85-9B85-069B16B0B84F"));
        }
コード例 #6
0
        public object Process(ICoreFactory factory, AssetId key, object asset)
        {
            if (asset == null)
            {
                throw new ArgumentNullException(nameof(asset));
            }
            var bitmap = (InterlacedBitmap)asset;

            return(new TrueColorTexture(key,
                                        key.ToString(), (uint)bitmap.Width, (uint)bitmap.Height,
                                        bitmap.Palette, bitmap.ImageData));
        }
コード例 #7
0
    void Test <T>(AssetId id,
                  AssetId[] prerequisites,
                  Func <T, ISerializer, T> serdes,
                  Func <T, T> canonicalize = null) where T : class
    {
        prerequisites ??= Array.Empty <AssetId>();
        var allIds = prerequisites.Append(id);

        var resultsDir = Path.Combine(_baseDir, "re", "ConversionTests");

        var baseAsset = (T)_baseApplier.LoadAsset(id);

        if (canonicalize != null)
        {
            baseAsset = canonicalize(baseAsset);
        }

        var(baseBytes, baseNotes) = Asset.Save(baseAsset, serdes);
        var baseJson = Asset.SaveJson(baseAsset, JsonUtil);

        var idStrings  = allIds.Select(x => $"{x.Type}.{x.Id}").ToArray();
        var assetTypes = allIds.Select(x => x.Type).Distinct().ToHashSet();

        var mapping = AssetMapping.Global;

        using (var unpacker = new AssetConverter(
                   mapping,
                   _disk,
                   JsonUtil,
                   new[] { BaseAssetMod },
                   UnpackedAssetMod))
        {
            unpacker.Convert(idStrings, assetTypes, null);
        }

        var unpackedAsset = (T)BuildApplier(UnpackedAssetMod, AssetMapping.Global).LoadAsset(id);

        Assert.NotNull(unpackedAsset);
        var(unpackedBytes, unpackedNotes) = Asset.Save(unpackedAsset, serdes);
        var unpackedJson = Asset.SaveJson(unpackedAsset, JsonUtil);

        Asset.Compare(resultsDir,
                      id.ToString(),
                      baseBytes,
                      unpackedBytes,
                      new[]
コード例 #8
0
        static IReadOnlyTexture <byte> Read(AssetId id, uint[] palette, Image <Rgba32> image, int subItemWidth, int subItemHeight)
        {
            var pixels = new byte[image.Width * image.Height];
            var frames = new List <Region>();

            if (!image.TryGetSinglePixelSpan(out Span <Rgba32> rgbaSpan))
            {
                throw new InvalidOperationException("Could not retrieve single span from Image");
            }

            var uintSpan = MemoryMarshal.Cast <Rgba32, uint>(rgbaSpan);
            var source   = new ReadOnlyImageBuffer <uint>(image.Width, image.Height, image.Width, uintSpan);
            var dest     = new ImageBuffer <byte>(image.Width, image.Height, image.Width, pixels);

            BlitUtil.UnpackSpriteSheet(palette, subItemWidth, subItemHeight, source, dest,
                                       (x, y, w, h) => frames.Add(new Region(x, y, w, h, image.Width, image.Height, 0)));

            while (IsFrameEmpty(frames.Last(), pixels, image.Width))
            {
                frames.RemoveAt(frames.Count - 1);
            }

            return(new SimpleTexture <byte>(id, id.ToString(), image.Width, image.Height, pixels, frames));
        }
コード例 #9
0
 public override string Log() => $"{AssetId.ToString().PadRight(15)}{Category.PadRight(17)}{Office.Name.PadRight(15)}{ProdName.PadRight(15)}{ModelName.PadRight(15)}{PurchaseDate.ToShortDateString().PadRight(15)}{Price.ToString().PadRight(15)}{Currency.PadRight(15)} {ExchangeRate.ToString().PadRight(10)}USD";
コード例 #10
0
 public override string ToString() => $"{From?.ToString("o") ?? string.Empty}-" +
 $"{To?.ToString("o") ?? string.Empty}-" +
 $"{AssetId?.ToString() ?? string.Empty}-" +
 $"{GroupId?.ToString() ?? string.Empty}";
コード例 #11
0
 public string GetKey()
 {
     return(AssetId.ToString());
 }
コード例 #12
0
ファイル: GameTrace.cs プロジェクト: vsafonkin/ualbion
 public void AssetLoaded(AssetId key, GameLanguage language, string path)
 {
     AssetLoaded(key.Type, key.Id, key.ToString(), language, path);
 }
コード例 #13
0
 public object Process(ICoreFactory factory, AssetId key, object asset)
 => new ImageSharpTrueColorTexture(key, key.ToString(), (Image <Rgba32>)asset);