Blender  V3.3
oiio_output_driver.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2021-2022 Blender Foundation */
3 
5 
7 
8 OIIOOutputDriver::OIIOOutputDriver(const string_view filepath,
9  const string_view pass,
11  : filepath_(filepath), pass_(pass), log_(log)
12 {
13 }
14 
16 {
17 }
18 
20 {
21  /* Only write the full buffer, no intermediate tiles. */
22  if (!(tile.size == tile.full_size)) {
23  return;
24  }
25 
26  log_(string_printf("Writing image %s", filepath_.c_str()));
27 
28  unique_ptr<ImageOutput> image_output(ImageOutput::create(filepath_));
29  if (image_output == nullptr) {
30  log_("Failed to create image file");
31  return;
32  }
33 
34  const int width = tile.size.x;
35  const int height = tile.size.y;
36 
37  ImageSpec spec(width, height, 4, TypeDesc::FLOAT);
38  if (!image_output->open(filepath_, spec)) {
39  log_("Failed to create image file");
40  return;
41  }
42 
43  vector<float> pixels(width * height * 4);
44  if (!tile.get_pass_pixels(pass_, 4, pixels.data())) {
45  log_("Failed to read render pass pixels");
46  return;
47  }
48 
49  /* Manipulate offset and stride to convert from bottom-up to top-down convention. */
50  image_output->write_image(TypeDesc::FLOAT,
51  pixels.data() + (height - 1) * width * 4,
52  AutoStride,
53  -width * 4 * sizeof(float),
54  AutoStride);
55  image_output->close();
56 }
57 
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void write_render_tile(const Tile &tile) override
function< void(const string &)> LogFunction
OIIOOutputDriver(const string_view filepath, const string_view pass, LogFunction log)
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
ccl_global const KernelWorkTile * tile
ccl_device_inline float3 log(float3 v)
Definition: math_float3.h:397
std::unique_ptr< IDProperty, IDPropertyDeleter > create(StringRefNull prop_name, int32_t value)
Allocate a new IDProperty of type IDP_INT, set its name and value.
@ FLOAT
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
Definition: string.cpp:22