SvgObject.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace WMFConverter.Svg
  7. {
  8. /// <summary>
  9. /// Scalable Vector Graphics - SVG base object.
  10. /// </summary>
  11. public abstract class SvgObject
  12. {
  13. #region Local Variables
  14. private SvgGdi _gdi;
  15. #endregion
  16. #region Properties
  17. /// <summary>
  18. /// Gdi object instance.
  19. /// </summary>
  20. /// <returns></returns>
  21. public SvgGdi GDI
  22. {
  23. get
  24. {
  25. return _gdi;
  26. }
  27. }
  28. #endregion
  29. #region Constructors
  30. /// <summary>
  31. /// Default constructor.
  32. /// </summary>
  33. /// <param name="gdi"></param>
  34. public SvgObject(SvgGdi gdi)
  35. {
  36. _gdi = gdi;
  37. }
  38. #endregion
  39. #region Public Methods
  40. /// <summary>
  41. /// Convert to real size.
  42. /// </summary>
  43. /// <param name="px"></param>
  44. /// <returns></returns>
  45. public int ToRealSize(int px)
  46. {
  47. return GDI.DC.Dpi * px / 90;
  48. }
  49. /// <summary>
  50. /// Convert int color to rgb color.
  51. /// </summary>
  52. /// <param name="color"></param>
  53. /// <returns></returns>
  54. public static string ToColor(int color)
  55. {
  56. int b = (0x00FF0000 & color) >> 16;
  57. int g = (0x0000FF00 & color) >> 8;
  58. int r = (0x000000FF & color);
  59. return "rgb(" + r + "," + g + "," + b + ")";
  60. }
  61. #endregion
  62. }
  63. }