ResolutionInfo.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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-2012 Tao Yue
  9. //
  10. // Portions of this file are provided under the BSD 3-clause License:
  11. // Copyright (c) 2006, Jonas Beckeman
  12. //
  13. // See LICENSE.txt for complete licensing and attribution information.
  14. //
  15. /////////////////////////////////////////////////////////////////////////////////
  16. using System;
  17. namespace PhotoshopFile
  18. {
  19. /// <summary>
  20. /// Summary description for ResolutionInfo.
  21. /// </summary>
  22. internal class ResolutionInfo : ImageResource
  23. {
  24. public override ResourceID ID
  25. {
  26. get { return ResourceID.ResolutionInfo; }
  27. }
  28. /// <summary>
  29. /// Horizontal DPI.
  30. /// </summary>
  31. public UFixed16_16 HDpi { get; set; }
  32. /// <summary>
  33. /// Vertical DPI.
  34. /// </summary>
  35. public UFixed16_16 VDpi { get; set; }
  36. /// <summary>
  37. /// 1 = pixels per inch, 2 = pixels per centimeter
  38. /// </summary>
  39. internal enum ResUnit
  40. {
  41. PxPerInch = 1,
  42. PxPerCm = 2
  43. }
  44. /// <summary>
  45. /// Display units for horizontal resolution. This only affects the
  46. /// user interface; the resolution is still stored in the PSD file
  47. /// as pixels/inch.
  48. /// </summary>
  49. public ResUnit HResDisplayUnit { get; set; }
  50. /// <summary>
  51. /// Display units for vertical resolution.
  52. /// </summary>
  53. public ResUnit VResDisplayUnit { get; set; }
  54. /// <summary>
  55. /// Physical units.
  56. /// </summary>
  57. internal enum Unit
  58. {
  59. Inches = 1,
  60. Centimeters = 2,
  61. Points = 3,
  62. Picas = 4,
  63. Columns = 5
  64. }
  65. public Unit WidthDisplayUnit { get; set; }
  66. public Unit HeightDisplayUnit { get; set; }
  67. public ResolutionInfo() : base(String.Empty)
  68. {
  69. }
  70. public ResolutionInfo(PsdBinaryReader reader, string name)
  71. : base(name)
  72. {
  73. this.HDpi = new UFixed16_16(reader.ReadUInt32());
  74. this.HResDisplayUnit = (ResUnit)reader.ReadInt16();
  75. this.WidthDisplayUnit = (Unit)reader.ReadInt16();
  76. this.VDpi = new UFixed16_16(reader.ReadUInt32());
  77. this.VResDisplayUnit = (ResUnit)reader.ReadInt16();
  78. this.HeightDisplayUnit = (Unit)reader.ReadInt16();
  79. }
  80. }
  81. }