imageResize.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file imageResize.h
  10. * @author drose
  11. * @date 2003-03-13
  12. */
  13. #ifndef IMAGERESIZE_H
  14. #define IMAGERESIZE_H
  15. #include "pandatoolbase.h"
  16. #include "imageFilter.h"
  17. /**
  18. * A program to read an image file and resize it to a larger or smaller image
  19. * file.
  20. */
  21. class ImageResize : public ImageFilter {
  22. public:
  23. ImageResize();
  24. void run();
  25. private:
  26. static bool dispatch_size_request(const std::string &opt, const std::string &arg, void *var);
  27. enum RequestType {
  28. RT_none,
  29. RT_pixel_size,
  30. RT_ratio,
  31. };
  32. class SizeRequest {
  33. public:
  34. INLINE SizeRequest();
  35. INLINE RequestType get_type() const;
  36. INLINE void set_pixel_size(int pixel_size);
  37. INLINE int get_pixel_size() const;
  38. INLINE int get_pixel_size(int orig_pixel_size) const;
  39. INLINE void set_ratio(double ratio);
  40. INLINE double get_ratio() const;
  41. INLINE double get_ratio(int orig_pixel_size) const;
  42. private:
  43. RequestType _type;
  44. union {
  45. int _pixel_size;
  46. double _ratio;
  47. } _e;
  48. };
  49. SizeRequest _x_size;
  50. SizeRequest _y_size;
  51. bool _use_gaussian_filter;
  52. double _filter_radius;
  53. };
  54. #include "imageResize.I"
  55. #endif