Blender V4.5
format_iris.cc File Reference
#include <algorithm>
#include <cstring>
#include "BLI_fileops.h"
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"
#include "IMB_colormanagement.hh"
#include "IMB_filetype.hh"
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"

Go to the source code of this file.

Classes

struct  IRIS_Header
struct  MFileOffset

Macros

#define IRIS_MAGIC   0732
#define HEADER_SIZE   512
#define RINTLUM   (79)
#define GINTLUM   (156)
#define BINTLUM   (21)
#define ILUM(r, g, b)
#define OFFSET_R   0 /* this is byte order dependent */
#define OFFSET_G   1
#define OFFSET_B   2
#define CHANOFFSET(z)
#define BPPMASK   0x00ff
#define ITYPE_RLE   0x0100
#define ISRLE(type)
#define BPP(type)
#define RLE(bpp)
#define MFILE_DATA(inf)
#define MFILE_STEP(inf, step)
#define MFILE_SEEK(inf, pos)
#define DIRTY_FLAG_EOF   (1 << 0)
#define DIRTY_FLAG_ENCODING   (1 << 1)
#define GS(x)
#define MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(p)
#define MFILE_CAPACITY_AT_PTR_OK_OR_FAIL(p)
#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next)
#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next)
#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL(iptr_next)
#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL(optr_next)

Functions

 BLI_STATIC_ASSERT (sizeof(IRIS_Header)==HEADER_SIZE, "Invalid header size")
static void readheader (MFileOffset *inf, IRIS_Header *image)
static int writeheader (FILE *outf, const IRIS_Header *image)
static ushort getshort (MFileOffset *inf)
static uint getlong (MFileOffset *mofs)
static void putshort (FILE *outf, ushort val)
static int putlong (FILE *outf, uint val)
static int writetab (FILE *outf, const uint *tab, int len)
static void readtab (MFileOffset *inf, uint *tab, int len)
static int expandrow (uchar *optr, const uchar *optr_end, const uchar *iptr, const uchar *iptr_end, int z)
static int expandrow2 (float *optr, const float *optr_end, const uchar *iptr, const uchar *iptr_end, int z)
static void interleaverow (uchar *lptr, const uchar *cptr, int z, int n)
static void interleaverow2 (float *lptr, const uchar *cptr, int z, int n)
static int compressrow (const uchar *lbuf, uchar *rlebuf, int z, int row_len)
static void lumrow (const uchar *rgbptr, uchar *lumptr, int n)
bool imb_is_a_iris (const uchar *mem, size_t size)
ImBufimb_loadiris (const uchar *mem, size_t size, int flags, ImFileColorSpace &)
static bool output_iris (const char *filepath, const uint *lptr, const int *zptr, const int xsize, const int ysize, const int zsize)
bool imb_saveiris (ImBuf *ibuf, const char *filepath, int)
Internal Image API
static void imbuf_rgba_to_abgr (ImBuf *ibuf)

Detailed Description

The SGI Image File Format. https://en.wikipedia.org/wiki/Silicon_Graphics_Image

Note
this format uses big-endian values.

Definition in file format_iris.cc.

Macro Definition Documentation

◆ BINTLUM

#define BINTLUM   (21)

Definition at line 59 of file format_iris.cc.

◆ BPP

#define BPP ( type)
Value:
((type) & BPPMASK)
#define BPPMASK

Definition at line 76 of file format_iris.cc.

Referenced by imb_loadiris().

◆ BPPMASK

#define BPPMASK   0x00ff

Definition at line 71 of file format_iris.cc.

◆ CHANOFFSET

#define CHANOFFSET ( z)
Value:
(3 - (z)) /* this is byte order dependent */
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117

Definition at line 68 of file format_iris.cc.

Referenced by lumrow(), and output_iris().

◆ DIRTY_FLAG_ENCODING

#define DIRTY_FLAG_ENCODING   (1 << 1)

Definition at line 102 of file format_iris.cc.

Referenced by expandrow(), and expandrow2().

◆ DIRTY_FLAG_EOF

#define DIRTY_FLAG_EOF   (1 << 0)

Definition at line 101 of file format_iris.cc.

◆ EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL [1/2]

#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL ( iptr_next)
Value:
if (UNLIKELY(iptr_next > iptr_end)) { \
goto fail; \
} \
((void)0)
#define UNLIKELY(x)

◆ EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL [2/2]

#define EXPAND_CAPACITY_AT_INPUT_OK_OR_FAIL ( iptr_next)
Value:
if (UNLIKELY(iptr_next > iptr_end)) { \
goto fail; \
} \
((void)0)

Referenced by expandrow(), and expandrow2().

◆ EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL [1/2]

#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL ( optr_next)
Value:
if (UNLIKELY(optr_next > optr_end)) { \
goto fail; \
} \
((void)0)

◆ EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL [2/2]

#define EXPAND_CAPACITY_AT_OUTPUT_OK_OR_FAIL ( optr_next)
Value:
if (UNLIKELY(optr_next > optr_end)) { \
goto fail; \
} \
((void)0)

Referenced by expandrow(), and expandrow2().

◆ GINTLUM

#define GINTLUM   (156)

Definition at line 58 of file format_iris.cc.

◆ GS

#define GS ( x)
Value:
(((uchar *)(x))[0] << 8 | ((uchar *)(x))[1])
unsigned char uchar

Definition at line 249 of file format_iris.cc.

Referenced by imb_is_a_iris().

◆ HEADER_SIZE

◆ ILUM

#define ILUM ( r,
g,
b )
Value:
(int(RINTLUM * (r) + GINTLUM * (g) + BINTLUM * (b)) >> 8)
#define GINTLUM
#define BINTLUM
#define RINTLUM

Definition at line 61 of file format_iris.cc.

Referenced by lumrow().

◆ IRIS_MAGIC

#define IRIS_MAGIC   0732

The SGI IRIS magic number. The value is [0x01 0xda] when read as a big-endian ushort.

Definition at line 31 of file format_iris.cc.

Referenced by imb_is_a_iris(), imb_loadiris(), and output_iris().

◆ ISRLE

#define ISRLE ( type)
Value:
(((type) & 0xff00) == ITYPE_RLE)
#define ITYPE_RLE

Definition at line 74 of file format_iris.cc.

Referenced by imb_loadiris().

◆ ITYPE_RLE

#define ITYPE_RLE   0x0100

Definition at line 73 of file format_iris.cc.

◆ MFILE_CAPACITY_AT_PTR_OK_OR_FAIL [1/2]

#define MFILE_CAPACITY_AT_PTR_OK_OR_FAIL ( p)
Value:
if (UNLIKELY((p) > mem_end)) { \
dirty_flag |= DIRTY_FLAG_EOF; \
goto fail_uncompressed; \
} \
((void)0)
#define DIRTY_FLAG_EOF

◆ MFILE_CAPACITY_AT_PTR_OK_OR_FAIL [2/2]

#define MFILE_CAPACITY_AT_PTR_OK_OR_FAIL ( p)
Value:
if (UNLIKELY((p) > mem_end)) { \
dirty_flag |= DIRTY_FLAG_EOF; \
goto fail_rle; \
} \
((void)0)

Referenced by imb_loadiris().

◆ MFILE_DATA

#define MFILE_DATA ( inf)
Value:
((void)0, ((inf)->_file_data + (inf)->_file_offset))

Definition at line 88 of file format_iris.cc.

Referenced by getlong(), getshort(), and imb_loadiris().

◆ MFILE_SEEK

#define MFILE_SEEK ( inf,
pos )
Value:
{ \
(inf)->_file_offset = pos; \
} \
((void)0)
uint pos

Definition at line 94 of file format_iris.cc.

Referenced by imb_loadiris().

◆ MFILE_STEP

#define MFILE_STEP ( inf,
step )
Value:
{ \
(inf)->_file_offset += step; \
} \
((void)0)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET

Definition at line 89 of file format_iris.cc.

Referenced by getlong(), getshort(), and imb_loadiris().

◆ OFFSET_B

#define OFFSET_B   2

Definition at line 65 of file format_iris.cc.

Referenced by lumrow().

◆ OFFSET_G

#define OFFSET_G   1

Definition at line 64 of file format_iris.cc.

Referenced by lumrow().

◆ OFFSET_R

#define OFFSET_R   0 /* this is byte order dependent */

Definition at line 63 of file format_iris.cc.

Referenced by lumrow().

◆ RINTLUM

#define RINTLUM   (79)

Definition at line 57 of file format_iris.cc.

◆ RLE

#define RLE ( bpp)
Value:
(ITYPE_RLE | (bpp))

Definition at line 77 of file format_iris.cc.

Referenced by output_iris().

Function Documentation

◆ BLI_STATIC_ASSERT()

BLI_STATIC_ASSERT ( sizeof(IRIS_Header) = =HEADER_SIZE,
"Invalid header size"  )

References HEADER_SIZE.

◆ compressrow()

int compressrow ( const uchar * lbuf,
uchar * rlebuf,
int z,
int row_len )
static

Definition at line 909 of file format_iris.cc.

References count, and z().

Referenced by output_iris().

◆ expandrow()

int expandrow ( uchar * optr,
const uchar * optr_end,
const uchar * iptr,
const uchar * iptr_end,
int z )
static

◆ expandrow2()

int expandrow2 ( float * optr,
const float * optr_end,
const uchar * iptr,
const uchar * iptr_end,
int z )
static

◆ getlong()

uint getlong ( MFileOffset * mofs)
static

Definition at line 170 of file format_iris.cc.

References MFILE_DATA, and MFILE_STEP.

Referenced by readtab().

◆ getshort()

ushort getshort ( MFileOffset * inf)
static

Definition at line 160 of file format_iris.cc.

References MFILE_DATA, and MFILE_STEP.

Referenced by readheader().

◆ imb_is_a_iris()

bool imb_is_a_iris ( const uchar * mem,
size_t size )

Definition at line 251 of file format_iris.cc.

References GS, IRIS_MAGIC, and size().

Referenced by imb_loadiris().

◆ imb_loadiris()

◆ imb_saveiris()

bool imb_saveiris ( ImBuf * ibuf,
const char * filepath,
int flags )

◆ imbuf_rgba_to_abgr()

void imbuf_rgba_to_abgr ( ImBuf * ibuf)
static

Change the ordering of the color bytes pointed to by rect from RGBA to ABGR. size * 4 color bytes are reordered.

Only this one is used liberally here, and in imbuf.

Definition at line 134 of file format_iris.cc.

References ImBuf::byte_buffer, ImBufByteBuffer::data, IMB_get_pixel_count(), and size().

Referenced by imb_loadiris(), and imb_saveiris().

◆ interleaverow()

void interleaverow ( uchar * lptr,
const uchar * cptr,
int z,
int n )
static

Definition at line 598 of file format_iris.cc.

References z().

Referenced by imb_loadiris().

◆ interleaverow2()

void interleaverow2 ( float * lptr,
const uchar * cptr,
int z,
int n )
static

Definition at line 607 of file format_iris.cc.

References z().

Referenced by imb_loadiris().

◆ lumrow()

void lumrow ( const uchar * rgbptr,
uchar * lumptr,
int n )
static

Definition at line 899 of file format_iris.cc.

References CHANOFFSET, ILUM, OFFSET_B, OFFSET_G, and OFFSET_R.

Referenced by output_iris().

◆ output_iris()

bool output_iris ( const char * filepath,
const uint * lptr,
const int * zptr,
const int xsize,
const int ysize,
const int zsize )
static
Parameters
filepathThe file path to write to.
lptran array of integers to an iris image file (each int represents one pixel).
zptrdepth-buffer (optional, may be nullptr).
xsizewith width of the pixel-array.
ysizeheight of the pixel-array.
zsizespecifies what kind of image file to write out.
  • 1: the luminance of the pixels are calculated, and a single channel black and white image is saved.
  • 3: an RGB image file is saved.
  • 4: an RGBA image file is saved.
  • 8: an RGBA image and a Z-buffer (non-null zptr).

Definition at line 803 of file format_iris.cc.

References BLI_assert_msg, BLI_fopen(), CHANOFFSET, compressrow(), IRIS_Header::dim, HEADER_SIZE, IRIS_Header::imagic, IRIS_MAGIC, len, lumrow(), IRIS_Header::max, MEM_freeN(), MEM_malloc_arrayN(), MEM_mallocN(), IRIS_Header::min, pos, RLE, IRIS_Header::type, writeheader(), writetab(), IRIS_Header::xsize, y, IRIS_Header::ysize, z(), and IRIS_Header::zsize.

Referenced by imb_saveiris().

◆ putlong()

int putlong ( FILE * outf,
uint val )
static

Definition at line 189 of file format_iris.cc.

Referenced by writeheader(), and writetab().

◆ putshort()

void putshort ( FILE * outf,
ushort val )
static

Definition at line 180 of file format_iris.cc.

Referenced by writeheader().

◆ readheader()

void readheader ( MFileOffset * inf,
IRIS_Header * image )
static

◆ readtab()

void readtab ( MFileOffset * inf,
uint * tab,
int len )
static

Definition at line 240 of file format_iris.cc.

References getlong(), and len.

Referenced by imb_loadiris().

◆ writeheader()

int writeheader ( FILE * outf,
const IRIS_Header * image )
static

◆ writetab()

int writetab ( FILE * outf,
const uint * tab,
int len )
static

Definition at line 229 of file format_iris.cc.

References len, and putlong().

Referenced by output_iris().