Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/imageprogs/imageResize.I

Go to the documentation of this file.
00001 // Filename: imageResize.I
00002 // Created by:  drose (13Mar03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: ImageResize::SizeRequest::Constructor
00022 //       Access: Public
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 INLINE ImageResize::SizeRequest::
00026 SizeRequest() {
00027   _type = RT_none;
00028 }
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //     Function: ImageResize::SizeRequest::get_type
00032 //       Access: Public
00033 //  Description: Returns the type of the size request, or RT_none if
00034 //               the request has not been specified.
00035 ////////////////////////////////////////////////////////////////////
00036 INLINE ImageResize::RequestType ImageResize::SizeRequest::
00037 get_type() const {
00038   return _type;
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: ImageResize::SizeRequest::set_pixel_size
00043 //       Access: Public
00044 //  Description: Sets the size request to store an explicit pixel
00045 //               size.
00046 ////////////////////////////////////////////////////////////////////
00047 INLINE void ImageResize::SizeRequest::
00048 set_pixel_size(int pixel_size) {
00049   _type = RT_pixel_size;
00050   _e._pixel_size = pixel_size;
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: ImageResize::SizeRequest::get_pixel_size
00055 //       Access: Public
00056 //  Description: Returns the explicit pixel size stored within the
00057 //               size request.
00058 ////////////////////////////////////////////////////////////////////
00059 INLINE int ImageResize::SizeRequest::
00060 get_pixel_size() const {
00061   nassertr(_type == RT_pixel_size, 0);
00062   return _e._pixel_size;
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: ImageResize::SizeRequest::get_pixel_size
00067 //       Access: Public
00068 //  Description: Returns the explicit pixel size stored within the
00069 //               size request, or if a ratio has been stored, returns
00070 //               the computed pixel size based on the original size.
00071 ////////////////////////////////////////////////////////////////////
00072 INLINE int ImageResize::SizeRequest::
00073 get_pixel_size(int orig_pixel_size) const {
00074   switch (_type) {
00075   case RT_pixel_size:
00076     return _e._pixel_size;
00077   case RT_ratio:
00078     return (int)(_e._ratio * orig_pixel_size + 0.5);
00079   default:
00080     return orig_pixel_size;
00081   }
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: ImageResize::SizeRequest::set_ratio
00086 //       Access: Public
00087 //  Description: Sets the size request to store a specific ratio.
00088 ////////////////////////////////////////////////////////////////////
00089 INLINE void ImageResize::SizeRequest::
00090 set_ratio(double ratio) {
00091   _type = RT_ratio;
00092   _e._ratio = ratio;
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: ImageResize::SizeRequest::get_ratio
00097 //       Access: Public
00098 //  Description: Returns the specific ratio stored within the
00099 //               size request.
00100 ////////////////////////////////////////////////////////////////////
00101 INLINE double ImageResize::SizeRequest::
00102 get_ratio() const {
00103   nassertr(_type == RT_ratio, 0);
00104   return _e._ratio;
00105 }
00106 
00107 ////////////////////////////////////////////////////////////////////
00108 //     Function: ImageResize::SizeRequest::get_ratio
00109 //       Access: Public
00110 //  Description: Returns the specific ratio stored within the
00111 //               size request, or if a pixel size has been stored,
00112 //               returns the computed ratio based on the original
00113 //               size.
00114 ////////////////////////////////////////////////////////////////////
00115 INLINE double ImageResize::SizeRequest::
00116 get_ratio(int orig_pixel_size) const {
00117   switch (_type) {
00118   case RT_ratio:
00119     return _e._ratio;
00120   case RT_pixel_size:
00121     return (double)_e._pixel_size / (double)orig_pixel_size;
00122   default:
00123     return 1.0;
00124   }
00125 }

Generated on Fri May 2 03:20:07 2003 for Panda-Tool by doxygen1.3