No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RleRowLengths.cs 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Photoshop PSD FileType Plugin for Paint.NET
  4. // http://psdplugin.codeplex.com/
  5. //
  6. // This software is provided under the MIT License:
  7. // Copyright (c) 2006-2007 Frank Blumenberg
  8. // Copyright (c) 2010-2014 Tao Yue
  9. //
  10. // See LICENSE.txt for complete licensing and attribution information.
  11. //
  12. /////////////////////////////////////////////////////////////////////////////////
  13. using System;
  14. using System.Linq;
  15. namespace PhotoshopFile
  16. {
  17. internal class RleRowLengths
  18. {
  19. public int[] Values { get; private set; }
  20. public long Total
  21. {
  22. get { return Values.Sum(x => (long)x); }
  23. }
  24. public int this[int i]
  25. {
  26. get { return Values[i]; }
  27. set { Values[i] = value; }
  28. }
  29. public RleRowLengths(int rowCount)
  30. {
  31. Values = new int[rowCount];
  32. }
  33. public RleRowLengths(PsdBinaryReader reader, int rowCount, bool isLargeDocument)
  34. : this(rowCount)
  35. {
  36. for (int i = 0; i < rowCount; i++)
  37. {
  38. Values[i] = isLargeDocument
  39. ? reader.ReadInt32()
  40. : reader.ReadUInt16();
  41. }
  42. }
  43. }
  44. }