29 #define MAXELEN 0x7fff
36 typedef unsigned char RGBE[4];
40 #define COPY_RGBE(c1, c2) \
41 (c2[RED] = c1[RED], c2[GRN] = c1[GRN], c2[BLU] = c1[BLU], c2[EXP] = c1[EXP])
45 const unsigned char *mem,
47 const unsigned char *mem_eof)
49 size_t i, rshift = 0,
len = xmax;
54 scan[0][
RED] = *mem++;
55 scan[0][
GRN] = *mem++;
56 scan[0][
BLU] = *mem++;
57 scan[0][
EXP] = *mem++;
58 if (scan[0][
RED] == 1 && scan[0][
GRN] == 1 && scan[0][
BLU] == 1) {
59 for (i = scan[0][
EXP] << rshift; i > 0 &&
len > 0; i--) {
76 const unsigned char *mem,
78 const unsigned char *mem_eof)
93 scan[0][
GRN] = *mem++;
94 scan[0][
BLU] = *mem++;
98 if (scan[0][
GRN] != 2 || scan[0][
BLU] & 128) {
104 if (
UNLIKELY(((scan[0][
BLU] << 8) | val) != xmax)) {
108 for (
size_t i = 0; i < 4; i++) {
112 for (
size_t j = 0; j < xmax;) {
121 scan[j++][i] = (
unsigned char)val;
125 if (
UNLIKELY(mem_eof - mem < code)) {
132 scan[j++][i] = *mem++;
146 if (rgbe[
EXP] == 0) {
150 float f = ldexp(1.0, rgbe[
EXP] - (
COLXS + 8));
151 fcol[
RED] = f * (rgbe[
RED] + 0.5f);
152 fcol[
GRN] = f * (rgbe[
GRN] + 0.5f);
153 fcol[
BLU] = f * (rgbe[
BLU] + 0.5f);
161 float d = (fcol[
RED] > fcol[
GRN]) ? fcol[
RED] : fcol[
GRN];
169 d = (
float)frexp(d, &
e) * 256.0f / d;
170 rgbe[
RED] = (
unsigned char)(fcol[
RED] * d);
171 rgbe[
GRN] = (
unsigned char)(fcol[
GRN] * d);
172 rgbe[
BLU] = (
unsigned char)(fcol[
BLU] * d);
190 const unsigned char magic[2] = {
'#',
'?'};
194 return memcmp(buf,
magic,
sizeof(
magic)) == 0;
208 const unsigned char *
ptr, *mem_eof = mem +
size;
209 char oriY[3], oriX[3];
220 if ((mem[
x - 1] ==
'\n') && (mem[
x] ==
'\n')) {
226 if ((found && (
x < (
size - 1))) == 0) {
235 memcpy(buf, &mem[
x],
MIN2(
sizeof(buf) - 1,
size -
x));
237 if (sscanf(buf,
"%2s %d %2s %d", (
char *)&oriY, &
height, (
char *)&oriX, &
width) != 4) {
249 ptr = (
const unsigned char *)strchr((
const char *)&mem[
x],
'\n');
266 ibuf->
ftype = IMB_FTYPE_RADHDR;
283 printf(
"WARNING! HDR decode error, image may be just truncated, or completely wrong...\n");
296 if (oriY[0] ==
'-') {
309 FILE *
file,
int width,
int channels,
const unsigned char *ibufscan,
const float *fpscan)
311 int beg, c2,
count = 0;
313 RGBE rgbe, *rgbe_scan;
322 for (
size_t i = 0, j = 0; i <
width; i++) {
324 fcol[
RED] = fpscan[j];
325 fcol[
GRN] = (
channels >= 2) ? fpscan[j + 1] : fpscan[j];
326 fcol[
BLU] = (
channels >= 3) ? fpscan[j + 2] : fpscan[j];
329 fcol[
RED] = (
float)ibufscan[j] / 255.0f;
330 fcol[
GRN] = (
float)((
channels >= 2) ? ibufscan[j + 1] : ibufscan[j]) / 255.0f;
331 fcol[
BLU] = (
float)((
channels >= 3) ? ibufscan[j + 2] : ibufscan[j]) / 255.0f;
347 putc((
unsigned char)(
width & 255),
file);
349 for (
size_t i = 0; i < 4; i++) {
353 (rgbe_scan[beg +
count][i] == rgbe_scan[beg][i]);
361 if (((beg - j) > 1) && ((beg - j) <
MINRUN)) {
363 while (rgbe_scan[c2++][i] == rgbe_scan[j][i]) {
365 putc((
unsigned char)(128 + beg - j),
file);
366 putc((
unsigned char)(rgbe_scan[j][i]),
file);
373 if ((c2 = beg - j) > 128) {
376 putc((
unsigned char)(c2),
file);
378 putc(rgbe_scan[j++][i],
file);
382 putc((
unsigned char)(128 +
count),
file);
383 putc(rgbe_scan[beg][i],
file);
391 return (ferror(
file) ? -1 : 0);
396 fprintf(
file,
"#?RADIANCE");
398 fprintf(
file,
"# %s",
"Created with Blender");
400 fprintf(
file,
"EXPOSURE=%25.13f", 1.0);
402 fprintf(
file,
"FORMAT=32-bit_rle_rgbe");
414 unsigned char *cp =
NULL;
434 printf(
"HDR write error\n");
typedef float(TangentPoint)[2]
File and directory operations.
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
_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 y
_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
Header file for allocimbuf.c.
@ COLOR_ROLE_DEFAULT_FLOAT
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
void IMB_rect_from_float(struct ImBuf *ibuf)
void IMB_flipy(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void colorspace_set_default_role(char *colorspace, int size, int role)
SyclQueue void void size_t num_bytes void
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
static const unsigned char * oldreadcolrs(RGBE *scan, const unsigned char *mem, int xmax, const unsigned char *mem_eof)
static const unsigned char * freadcolrs(RGBE *scan, const unsigned char *mem, int xmax, const unsigned char *mem_eof)
static void writeHeader(FILE *file, int width, int height)
struct ImBuf * imb_loadhdr(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
static void FLOAT2RGBE(const fCOLOR fcol, RGBE rgbe)
bool imb_is_a_hdr(const unsigned char *buf, const size_t size)
static int fwritecolrs(FILE *file, int width, int channels, const unsigned char *ibufscan, const float *fpscan)
bool imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags)
#define COPY_RGBE(c1, c2)
static void RGBE2FLOAT(RGBE rgbe, fCOLOR fcol)
static int magic(const Tex *tex, const float texvec[3], TexResult *texres)