diff --git a/examples/viewer/opengl/main.cpp b/examples/viewer/opengl/main.cpp index c50366e84..15d98faf0 100644 --- a/examples/viewer/opengl/main.cpp +++ b/examples/viewer/opengl/main.cpp @@ -105,7 +105,7 @@ int main() // If you want to use one of the other modes, you have to do the conversion // yourself. // - colorTexture.Update(reinterpret_cast(colorImage.get_buffer())); + colorTexture.Update(colorImage.get_buffer()); } // Show the windows @@ -154,7 +154,7 @@ void ColorizeDepthImage(const k4a::image &depthImage, buffer->resize(static_cast(width * height)); - const uint16_t *depthData = reinterpret_cast(depthImage.get_buffer()); + const uint16_t *depthData = depthImage.get_buffer(); for (int h = 0; h < height; ++h) { for (int w = 0; w < width; ++w) diff --git a/include/k4a/k4a.hpp b/include/k4a/k4a.hpp index c86299882..31ff403ab 100644 --- a/include/k4a/k4a.hpp +++ b/include/k4a/k4a.hpp @@ -262,18 +262,20 @@ class image * * \sa k4a_image_get_buffer */ - uint8_t *get_buffer() noexcept + template + T *get_buffer() noexcept { - return k4a_image_get_buffer(m_handle); + return reinterpret_cast(k4a_image_get_buffer(m_handle)); } /** Get the image buffer * * \sa k4a_image_get_buffer */ - const uint8_t *get_buffer() const noexcept + template + const T *get_buffer() const noexcept { - return k4a_image_get_buffer(m_handle); + return reinterpret_cast(k4a_image_get_buffer(m_handle)); } /** Get the image buffer size in bytes