您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ScaleFilters.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright (C) 2006 TightVNC Team. All Rights Reserved.
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. // -=- ScaleFilters.h
  19. //
  20. // Definitions of the 1-D filters and routines using for the image scaling.
  21. //
  22. //
  23. namespace rfb {
  24. #define SCALE_ERROR (1e-7)
  25. #define BITS_OF_CHANEL 8
  26. #define BITS_OF_WEIGHT 14
  27. #define FINALSHIFT (2 * BITS_OF_WEIGHT - BITS_OF_CHANEL)
  28. #define WEIGHT_OF_ONE (1 << BITS_OF_WEIGHT)
  29. typedef double (*filter_func)(double x);
  30. const double pi = 3.14159265358979;
  31. const unsigned int scaleFilterNearestNeighbor = 0;
  32. const unsigned int scaleFilterBilinear = 1;
  33. const unsigned int scaleFilterBicubic = 2;
  34. const unsigned int scaleFilterMaxNumber = 2;
  35. const unsigned int defaultScaleFilter = scaleFilterBilinear;
  36. //
  37. // -=- Scale filters structures and routines
  38. //
  39. // Scale filter stuct
  40. typedef struct {
  41. char name[30]; // Filter name
  42. double radius; // Radius where filter function is nonzero
  43. filter_func func; // Pointer to filter function
  44. } SFilter;
  45. // Scale filter weight table
  46. typedef struct {
  47. short i0, i1; // Filter function interval, [i0..i1)
  48. short *weight; // Weight coefficients on the filter function interval
  49. } SFilterWeightTab;
  50. // ScaleFilters class helps us using a set of 1-d scale filters.
  51. class ScaleFilters {
  52. public:
  53. ScaleFilters() { initFilters(); };
  54. SFilter &operator[](unsigned int filter_id);
  55. int getFilterIdByName(char *filterName);
  56. void makeWeightTabs(int filter, int src_x, int dst_x, SFilterWeightTab **weightTabs);
  57. protected:
  58. void initFilters();
  59. SFilter create(const char *name_, double radius_, filter_func func_);
  60. SFilter filters[scaleFilterMaxNumber+1];
  61. };
  62. };