Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/viewer/opengl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const BgraPixel *>(colorImage.get_buffer()));
colorTexture.Update(colorImage.get_buffer<const BgraPixel>());
}

// Show the windows
Expand Down Expand Up @@ -154,7 +154,7 @@ void ColorizeDepthImage(const k4a::image &depthImage,

buffer->resize(static_cast<size_t>(width * height));

const uint16_t *depthData = reinterpret_cast<const uint16_t *>(depthImage.get_buffer());
const uint16_t *depthData = depthImage.get_buffer<const uint16_t>();
for (int h = 0; h < height; ++h)
{
for (int w = 0; w < width; ++w)
Expand Down
10 changes: 6 additions & 4 deletions include/k4a/k4a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,20 @@ class image
*
* \sa k4a_image_get_buffer
*/
uint8_t *get_buffer() noexcept
template<typename T = uint8_t>
T *get_buffer() noexcept
{
return k4a_image_get_buffer(m_handle);
return reinterpret_cast<T*>(k4a_image_get_buffer(m_handle));
}

/** Get the image buffer
*
* \sa k4a_image_get_buffer
*/
const uint8_t *get_buffer() const noexcept
template<typename T = uint8_t>
const T *get_buffer() const noexcept
{
return k4a_image_get_buffer(m_handle);
return reinterpret_cast<T*>(k4a_image_get_buffer(m_handle));
}

/** Get the image buffer size in bytes
Expand Down