00001
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "vil_transpose.h"
00017
00018 vil_image_resource_sptr vil_transpose(const vil_image_resource_sptr &src)
00019 {
00020 return new vil_transpose_image_resource(src);
00021 }
00022
00023 vil_transpose_image_resource::vil_transpose_image_resource(vil_image_resource_sptr const& src):
00024 src_(src)
00025 {
00026 }
00027
00028 vil_image_view_base_sptr vil_transpose_image_resource::get_copy_view(unsigned i0, unsigned ni,
00029 unsigned j0, unsigned nj) const
00030 {
00031 vil_image_view_base_sptr vs = src_->get_copy_view(j0, nj, i0, ni);
00032 if (!vs) return 0;
00033
00034 switch (vs->pixel_format())
00035 {
00036 #define macro( F, T ) \
00037 case F : \
00038 return new vil_image_view<T > (vil_transpose(static_cast<const vil_image_view<T >&>(*vs)));
00039
00040 macro(VIL_PIXEL_FORMAT_BYTE, vxl_byte)
00041 macro(VIL_PIXEL_FORMAT_SBYTE, vxl_sbyte)
00042 #if VXL_HAS_INT_64
00043 macro(VIL_PIXEL_FORMAT_UINT_64, vxl_uint_64)
00044 macro(VIL_PIXEL_FORMAT_INT_64, vxl_int_64)
00045 #endif
00046 macro(VIL_PIXEL_FORMAT_UINT_32, vxl_uint_32)
00047 macro(VIL_PIXEL_FORMAT_INT_32, vxl_int_32)
00048 macro(VIL_PIXEL_FORMAT_UINT_16, vxl_uint_16)
00049 macro(VIL_PIXEL_FORMAT_INT_16, vxl_int_16)
00050 macro(VIL_PIXEL_FORMAT_FLOAT, float)
00051 macro(VIL_PIXEL_FORMAT_DOUBLE, double)
00052 macro(VIL_PIXEL_FORMAT_COMPLEX_FLOAT , vcl_complex<float>)
00053 macro(VIL_PIXEL_FORMAT_COMPLEX_DOUBLE , vcl_complex<double>)
00054 #undef macro
00055 default:
00056 return 0;
00057 }
00058 }
00059
00060 vil_image_view_base_sptr vil_transpose_image_resource::get_view(unsigned i0, unsigned ni,
00061 unsigned j0, unsigned nj) const
00062 {
00063 vil_image_view_base_sptr vs = src_->get_view(j0, nj, i0, ni);
00064 if (!vs) return 0;
00065
00066 switch (vs->pixel_format())
00067 {
00068 #define macro( F, T ) \
00069 case F : \
00070 return new vil_image_view<T > (vil_transpose(static_cast<const vil_image_view<T >&>(*vs)));
00071
00072 macro(VIL_PIXEL_FORMAT_BYTE, vxl_byte)
00073 macro(VIL_PIXEL_FORMAT_SBYTE, vxl_sbyte)
00074 #if VXL_HAS_INT_64
00075 macro(VIL_PIXEL_FORMAT_UINT_64, vxl_uint_64)
00076 macro(VIL_PIXEL_FORMAT_INT_64, vxl_int_64)
00077 #endif
00078 macro(VIL_PIXEL_FORMAT_UINT_32, vxl_uint_32)
00079 macro(VIL_PIXEL_FORMAT_INT_32, vxl_int_32)
00080 macro(VIL_PIXEL_FORMAT_UINT_16, vxl_uint_16)
00081 macro(VIL_PIXEL_FORMAT_INT_16, vxl_int_16)
00082 macro(VIL_PIXEL_FORMAT_FLOAT, float)
00083 macro(VIL_PIXEL_FORMAT_DOUBLE, double)
00084 macro(VIL_PIXEL_FORMAT_COMPLEX_FLOAT , vcl_complex<float>)
00085 macro(VIL_PIXEL_FORMAT_COMPLEX_DOUBLE , vcl_complex<double>)
00086 #undef macro
00087 default:
00088 return 0;
00089 }
00090 }
00091
00092
00093 bool vil_transpose_image_resource::put_view(const vil_image_view_base& im, unsigned i0,
00094 unsigned j0)
00095 {
00096 switch (im.pixel_format())
00097 {
00098 #define macro( F, T ) \
00099 case F : \
00100 return src_->put_view(vil_transpose(static_cast<const vil_image_view<T >&>(im)), j0, i0);
00101
00102 macro(VIL_PIXEL_FORMAT_BYTE, vxl_byte)
00103 macro(VIL_PIXEL_FORMAT_SBYTE, vxl_sbyte)
00104 #if VXL_HAS_INT_64
00105 macro(VIL_PIXEL_FORMAT_UINT_64, vxl_uint_64)
00106 macro(VIL_PIXEL_FORMAT_INT_64, vxl_int_64)
00107 #endif
00108 macro(VIL_PIXEL_FORMAT_UINT_32, vxl_uint_32)
00109 macro(VIL_PIXEL_FORMAT_INT_32, vxl_int_32)
00110 macro(VIL_PIXEL_FORMAT_UINT_16, vxl_uint_16)
00111 macro(VIL_PIXEL_FORMAT_INT_16, vxl_int_16)
00112 macro(VIL_PIXEL_FORMAT_FLOAT, float)
00113 macro(VIL_PIXEL_FORMAT_DOUBLE, double)
00114 macro(VIL_PIXEL_FORMAT_COMPLEX_FLOAT , vcl_complex<float>)
00115 macro(VIL_PIXEL_FORMAT_COMPLEX_DOUBLE , vcl_complex<double>)
00116 #undef macro
00117 default:
00118 return false;
00119 }
00120 }