EtcIndividualTrys.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 IndividualTrys
  21. {
  22. public:
  23. static const unsigned int MAX_RADIUS = 1;
  24. IndividualTrys(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. inline static int MoveAwayFromEdge(int a_i, int a_iDistance)
  30. {
  31. if (a_i < (0+ a_iDistance))
  32. {
  33. return (0 + a_iDistance);
  34. }
  35. else if (a_i > (15- a_iDistance))
  36. {
  37. return (15 - a_iDistance);
  38. }
  39. return a_i;
  40. }
  41. class Try
  42. {
  43. public :
  44. static const unsigned int SELECTORS = 8; // per half
  45. int m_iRed;
  46. int m_iGreen;
  47. int m_iBlue;
  48. unsigned int m_uiCW;
  49. unsigned int m_auiSelectors[SELECTORS];
  50. float m_fError;
  51. };
  52. class Half
  53. {
  54. public:
  55. static const unsigned int MAX_TRYS = 27;
  56. void Init(int a_iRed, int a_iGreen, int a_iBlue,
  57. const unsigned int *a_pauiPixelMapping,
  58. unsigned int a_uiRadius);
  59. // center of trys
  60. int m_iRed;
  61. int m_iGreen;
  62. int m_iBlue;
  63. const unsigned int *m_pauiPixelMapping;
  64. unsigned int m_uiRadius;
  65. unsigned int m_uiTrys;
  66. Try m_atry[MAX_TRYS];
  67. Try *m_ptryBest;
  68. };
  69. Half m_half1;
  70. Half m_half2;
  71. };
  72. // ----------------------------------------------------------------------------------------------------
  73. //
  74. } // namespace Etc