ConvertRasterImageBenchmark.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. use Mike42\GfxPhp\Image;
  3. /**
  4. * @BeforeMethods({"init"})
  5. * @Revs(1000)
  6. */
  7. class ConvertRasterImageBenchmark
  8. {
  9. private static $bw100;
  10. private static $gray100;
  11. private static $indexed100;
  12. private static $rgb100;
  13. public function init()
  14. {
  15. self::$rgb100 = Image::fromFile(__DIR__ . "/../../resources/pngsuite/z09n2c08.png");
  16. self::$bw100 = self::$rgb100 -> toBlackAndWhite();
  17. self::$indexed100 = self::$rgb100 -> toIndexed();
  18. self::$gray100 = self::$rgb100 -> toGrayscale();
  19. }
  20. /**
  21. * @Subject
  22. */
  23. public function convertBwToBw()
  24. {
  25. self::$bw100->toBlackAndWhite();
  26. }
  27. /**
  28. * @Subject
  29. */
  30. public function convertBwToGray()
  31. {
  32. self::$bw100->toGrayscale();
  33. }
  34. /**
  35. * @Subject
  36. */
  37. public function convertBwToIndexed()
  38. {
  39. self::$bw100->toIndexed();
  40. }
  41. /**
  42. * @Subject
  43. */
  44. public function convertBwToRgb()
  45. {
  46. self::$bw100->toRgb();
  47. }
  48. /**
  49. * @Subject
  50. */
  51. public function convertGrayToBw()
  52. {
  53. self::$gray100->toBlackAndWhite();
  54. }
  55. /**
  56. * @Subject
  57. */
  58. public function convertGrayToGray()
  59. {
  60. self::$gray100->toGrayscale();
  61. }
  62. /**
  63. * @Subject
  64. */
  65. public function convertGrayToIndexed()
  66. {
  67. self::$gray100->toIndexed();
  68. }
  69. /**
  70. * @Subject
  71. */
  72. public function convertGrayToRgb()
  73. {
  74. self::$gray100->toRgb();
  75. }
  76. /**
  77. * @Subject
  78. */
  79. public function convertIndexedToBw()
  80. {
  81. self::$indexed100->toBlackAndWhite();
  82. }
  83. /**
  84. * @Subject
  85. */
  86. public function convertIndexedToGray()
  87. {
  88. self::$indexed100->toGrayscale();
  89. }
  90. /**
  91. * @Subject
  92. */
  93. public function convertIndexedToIndexed()
  94. {
  95. self::$indexed100->toIndexed();
  96. }
  97. /**
  98. * @Subject
  99. */
  100. public function convertIndexedToRgb()
  101. {
  102. self::$indexed100->toRgb();
  103. }
  104. /**
  105. * @Subject
  106. */
  107. public function convertRgbToBw()
  108. {
  109. self::$rgb100->toBlackAndWhite();
  110. }
  111. /**
  112. * @Subject
  113. */
  114. public function convertRgbToGray()
  115. {
  116. self::$rgb100->toGrayscale();
  117. }
  118. /**
  119. * @Subject
  120. */
  121. public function convertRgbToIndexed()
  122. {
  123. self::$rgb100->toIndexed();
  124. }
  125. /**
  126. * @Subject
  127. */
  128. public function convertRgbToRgb()
  129. {
  130. self::$rgb100->toRgb();
  131. }
  132. }