30 #ifndef MLN_CONVERT_TO_QIMAGE_NOCOPY_HH
31 # define MLN_CONVERT_TO_QIMAGE_NOCOPY_HH
33 # include <QtGui/QImage>
35 # include <mln/core/concept/image.hh>
36 # include <mln/geom/nrows.hh>
37 # include <mln/geom/ncols.hh>
38 # include <mln/border/resize.hh>
41 # include <mln/value/qt/rgb32.hh>
42 # include <mln/value/rgb8.hh>
44 # if QT_VERSION < 0x040000
45 # error "Your version of Qt is too old and is not supported."
62 QImage to_qimage_nocopy_qt_rgb32(
const Image<I>& ima_)
64 const I& ima = exact(ima_);
65 mln_precondition(ima.is_valid());
71 typedef mln_value(I) V;
72 QImage qima((uchar *)(&ima(ima.domain().pmin())), ncols, nrows,
73 (ncols + 2 * ima.border()) * sizeof(V),
74 QImage::Format_RGB32);
80 # if QT_VERSION >= 0x040400
84 QImage to_qimage_nocopy_rgb8(
const Image<I>& ima_)
86 const I& ima = exact(ima_);
87 mln_precondition(ima.is_valid());
93 typedef mln_value(I) V;
94 QImage qima((uchar *)(&ima(ima.domain().pmin())), ncols, nrows,
95 (ncols + 2 * ima.border()) * sizeof(V),
96 QImage::Format_RGB888);
114 template <
typename I>
116 QImage to_qimage_nocopy_dispatch(
const Image<I>& ima,
117 const value::qt::rgb32&)
119 return impl::to_qimage_nocopy_qt_rgb32(ima);
123 # if QT_VERSION >= 0x040400
125 template <
typename I>
127 QImage to_qimage_nocopy_dispatch(
const Image<I>& ima,
130 return impl::to_qimage_nocopy_rgb8(ima);
136 template <
typename I,
typename V>
138 QImage to_qimage_nocopy_dispatch(
const Image<I>&, V&)
141 mlc_abort(I)::check();
146 template <
typename I>
148 QImage to_qimage_nocopy_dispatch(
const Image<I>& ima)
150 typedef mln_value(I) V;
151 return to_qimage_nocopy_dispatch(ima, V());
160 template <typename I>
162 QImage to_qimage_nocopy(const Image<I>& ima_)
164 trace::entering(
"convert::to_qimage_nocopy");
166 const I& ima = exact(ima_);
167 mln_precondition(ima.is_valid());
169 QImage output = internal::to_qimage_nocopy_dispatch(ima);
171 trace::exiting(
"convert::to_qimage_nocopy");
180 #endif // ! MLN_CONVERT_TO_QIMAGE_NOCOPY_HH