Singularity/Library/PackageCache/com.unity.2d.psdimporter@6.0.7/Editor/PSDPlugin/PsdFile/RleRowLengths.cs

51 lines
1.3 KiB
C#
Raw Normal View History

2024-05-06 14:45:45 -04:00
/////////////////////////////////////////////////////////////////////////////////
//
// Photoshop PSD FileType Plugin for Paint.NET
// http://psdplugin.codeplex.com/
//
// This software is provided under the MIT License:
// Copyright (c) 2006-2007 Frank Blumenberg
// Copyright (c) 2010-2014 Tao Yue
//
// See LICENSE.txt for complete licensing and attribution information.
//
/////////////////////////////////////////////////////////////////////////////////
using System;
using System.Linq;
namespace PhotoshopFile
{
internal class RleRowLengths
{
public int[] Values { get; private set; }
public long Total
{
get { return Values.Sum(x => (long)x); }
}
public int this[int i]
{
get { return Values[i]; }
set { Values[i] = value; }
}
public RleRowLengths(int rowCount)
{
Values = new int[rowCount];
}
public RleRowLengths(PsdBinaryReader reader, int rowCount, bool isLargeDocument)
: this(rowCount)
{
for (int i = 0; i < rowCount; i++)
{
Values[i] = isLargeDocument
? reader.ReadInt32()
: reader.ReadUInt16();
}
}
}
}