1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_INTEROP_QT_QIMAGE_HPP
12 #define BOOST_COMPUTE_INTEROP_QT_QIMAGE_HPP
14 #include <boost/throw_exception.hpp>
16 #include <boost/compute/command_queue.hpp>
17 #include <boost/compute/exception/opencl_error.hpp>
18 #include <boost/compute/image/image2d.hpp>
19 #include <boost/compute/image/image_format.hpp>
20 #include <boost/compute/utility/dim.hpp>
27 inline image_format qt_qimage_format_to_image_format(const QImage::Format &format)
29 if(format == QImage::Format_RGB32){
30 return image_format(image_format::bgra, image_format::unorm_int8);
33 BOOST_THROW_EXCEPTION(opencl_error(CL_IMAGE_FORMAT_NOT_SUPPORTED));
36 inline QImage::Format qt_image_format_to_qimage_format(const image_format &format)
38 if(format == image_format(image_format::bgra, image_format::unorm_int8)){
39 return QImage::Format_RGB32;
42 return QImage::Format_Invalid;
45 inline image_format qt_qimage_get_format(const QImage &image)
47 return qt_qimage_format_to_image_format(image.format());
50 inline void qt_copy_qimage_to_image2d(const QImage &qimage,
54 queue.enqueue_write_image(image, image.origin(), image.size(), qimage.constBits());
57 inline void qt_copy_image2d_to_qimage(const image2d &image,
61 queue.enqueue_read_image(
62 image, dim(0, 0), dim(qimage.width(), qimage.height()), qimage.bits()
66 } // end compute namespace
67 } // end boost namespace
69 #endif // BOOST_COMPUTE_INTEROP_QT_QIMAGE_HPP