EndianReverser.cs 1.3 KB

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-2016 Tao Yue
  9. //
  10. // See LICENSE.txt for complete licensing and attribution information.
  11. //
  12. /////////////////////////////////////////////////////////////////////////////////
  13. using System;
  14. namespace PhotoshopFile.Compression
  15. {
  16. internal class EndianReverser : ImageData
  17. {
  18. private ImageData imageData;
  19. protected override bool AltersWrittenData
  20. {
  21. get { return true; }
  22. }
  23. public EndianReverser(ImageData imageData)
  24. : base(imageData.Size, imageData.BitDepth)
  25. {
  26. this.imageData = imageData;
  27. }
  28. internal override void Read(byte[] buffer)
  29. {
  30. imageData.Read(buffer);
  31. var numPixels = Size.Width * Size.Height;
  32. if (numPixels == 0)
  33. {
  34. return;
  35. }
  36. Util.SwapByteArray(BitDepth, buffer, 0, numPixels);
  37. }
  38. public override byte[] ReadCompressed()
  39. {
  40. return imageData.ReadCompressed();
  41. }
  42. }
  43. }