EtcDifferentialTrys.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright 2015 The Etc2Comp Authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include "EtcColorFloatRGBA.h"
  18. namespace Etc
  19. {
  20. class DifferentialTrys
  21. {
  22. public:
  23. static const unsigned int MAX_RADIUS = 2;
  24. DifferentialTrys(ColorFloatRGBA a_frgbaColor1,
  25. ColorFloatRGBA a_frgbaColor2,
  26. const unsigned int *a_pauiPixelMapping1,
  27. const unsigned int *a_pauiPixelMapping2,
  28. unsigned int a_uiRadius,
  29. int a_iGrayOffset1, int a_iGrayOffset2);
  30. inline static int MoveAwayFromEdge(int a_i, int a_iDistance)
  31. {
  32. if (a_i < (0+ a_iDistance))
  33. {
  34. return (0 + a_iDistance);
  35. }
  36. else if (a_i > (31- a_iDistance))
  37. {
  38. return (31 - a_iDistance);
  39. }
  40. return a_i;
  41. }
  42. class Try
  43. {
  44. public :
  45. static const unsigned int SELECTORS = 8; // per half
  46. int m_iRed;
  47. int m_iGreen;
  48. int m_iBlue;
  49. unsigned int m_uiCW;
  50. unsigned int m_auiSelectors[SELECTORS];
  51. float m_fError;
  52. };
  53. class Half
  54. {
  55. public:
  56. static const unsigned int MAX_TRYS = 125;
  57. void Init(int a_iRed, int a_iGreen, int a_iBlue,
  58. const unsigned int *a_pauiPixelMapping,
  59. unsigned int a_uiRadius);
  60. // center of trys
  61. int m_iRed;
  62. int m_iGreen;
  63. int m_iBlue;
  64. const unsigned int *m_pauiPixelMapping;
  65. unsigned int m_uiRadius;
  66. unsigned int m_uiTrys;
  67. Try m_atry[MAX_TRYS];
  68. Try *m_ptryBest;
  69. };
  70. Half m_half1;
  71. Half m_half2;
  72. bool m_boolSeverelyBentColors;
  73. };
  74. // ----------------------------------------------------------------------------------------------------
  75. //
  76. } // namespace Etc