image.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
3 
4 #include "image.h"
5 
6 #pragma pack(push, 1) // All structs in this file are assumed to be byte-packed
7 namespace librealsense
8 {
9 
11  // Image size computation //
13 
15  {
16  if (format == RS2_FORMAT_YUYV || (format == RS2_FORMAT_UYVY)) assert(width % 2 == 0);
17  if (format == RS2_FORMAT_RAW10) assert(width % 4 == 0);
18  return width * height * get_image_bpp(format) / 8;
19  }
20 
22  {
23  switch (format)
24  {
25  case RS2_FORMAT_Z16: return 16;
26  case RS2_FORMAT_DISPARITY16: return 16;
27  case RS2_FORMAT_DISPARITY32: return 32;
28  case RS2_FORMAT_XYZ32F: return 12 * 8;
29  case RS2_FORMAT_YUYV: return 16;
30  case RS2_FORMAT_RGB8: return 24;
31  case RS2_FORMAT_BGR8: return 24;
32  case RS2_FORMAT_RGBA8: return 32;
33  case RS2_FORMAT_BGRA8: return 32;
34  case RS2_FORMAT_Y8: return 8;
35  case RS2_FORMAT_Y16: return 16;
36  case RS2_FORMAT_RAW10: return 16; // return 16 bits instead of 10 bits in order to prevent allocated frame buffer size < actual data size.
37  case RS2_FORMAT_Y10BPACK: return 16;
38  case RS2_FORMAT_RAW16: return 16;
39  case RS2_FORMAT_RAW8: return 8;
40  case RS2_FORMAT_UYVY: return 16;
41  case RS2_FORMAT_GPIO_RAW: return 1;
42  case RS2_FORMAT_MOTION_RAW: return 1;
43  case RS2_FORMAT_MOTION_XYZ32F: return 1;
44  case RS2_FORMAT_6DOF: return 1;
45  case RS2_FORMAT_MJPEG: return 8;
46  case RS2_FORMAT_Y8I: return 16;
47  case RS2_FORMAT_Y12I: return 24;
48  case RS2_FORMAT_INZI: return 32;
49  case RS2_FORMAT_INVI: return 16;
50  case RS2_FORMAT_W10: return 32;
51  case RS2_FORMAT_Z16H: return 16;
52  case RS2_FORMAT_FG: return 16;
53  default: assert(false); return 0;
54  }
55  }
56 
58  // Frame rotation routines //
61  {
62  return resolution{ res.height , res.width};
63  }
64 
66  {
67  return resolution{ res.height , res.width * 2 };
68  }
69 
70 }
71 
72 #pragma pack(pop)
size_t get_image_size(int width, int height, rs2_format format)
Definition: image.cpp:14
resolution l500_confidence_resolution(resolution res)
Definition: image.cpp:65
GLint GLsizei GLsizei height
GLint GLint GLsizei GLint GLenum format
rs2_format
A stream&#39;s format identifies how binary data is encoded within a frame.
Definition: rs_sensor.h:59
resolution rotate_resolution(resolution res)
Definition: image.cpp:60
GLuint res
Definition: glext.h:8856
int get_image_bpp(rs2_format format)
Definition: image.cpp:21
GLint GLsizei width


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:16