Orange branch: OpenEXR finally in Blender!

Credits go to Gernot Ziegler, who originally coded EXR support, and to
Austin  Benesh for bringing it further. Kent Mein provided a lot of code
for integrating float buffers in Blender imbuf and ImBuf API cleanup,
and provided Make and Scons and static linking.

At this moment; the EXR libraries are a *dependency*, so you cannot get
the Orange branch compiled without having OpenEXR installed. Get the
(precompiled or sources) stuff from www.openexr.com. Current default is
that the headers and lib resides in /user/local/

Several changes/additions/fixes were added:

- EXR code only supported 'half' format (16 bits per channel). I've added
  float writing, but for reading it I need tomorrow. :)
- Quite some clumsy copying of data happened in EXR code.
- cleaned up the api calls already a bit, preparing for more advanced
  support
- Zbuffers were saved 16 bits, now 32 bits
- automatic adding of .exr extensions went wrong

Imbuf:

- added proper imbuf->flags and imbuf->mall support for float buffers, it
  was created for *each* imbuf. :)
- found bugs for float buffers in scaling and flipping. Code there will
  need more checks still
- imbuf also needs to be verified to behave properly when no 32 bits
  rect exists (for saving for example)

TODO:

- support internal float images for textures, backbuf, AO probes, and
  display in Image window

Hope this commit won't screwup syncing with bf-blender... :/
This commit is contained in:
2006-01-09 00:40:35 +00:00
parent 104ab9b103
commit 014aa7261e
53 changed files with 1754 additions and 661 deletions

View File

@@ -17,6 +17,9 @@ SConscript(['avi/SConscript',
'src/SConscript',
'yafray/SConscript'])
if user_options_dict['USE_OPENEXR'] == 1:
SConscript (['imbuf/intern/openexr/SConscript'])
if user_options_dict['USE_INTERNATIONAL'] == 1:
SConscript (['ftfont/SConscript'])

View File

@@ -124,7 +124,7 @@ typedef struct Global {
struct VFont *selfont;
struct ListBase ttfdata;
/* libtiff flag */
/* libtiff flag used to determine if shared library loaded for libtiff*/
int have_libtiff;
/* this variable is written to / read from FileGlobal->fileflags */

View File

@@ -83,3 +83,7 @@ ifeq ($(WITH_FREETYPE2), true)
CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2
endif
ifeq ($(WITH_OPENEXR), true)
CPPFLAGS += -DWITH_OPENEXR
endif

View File

@@ -341,8 +341,15 @@ void addImageExtension(char *string)
extension= ".bmp";
}
else if(G.have_libtiff && (G.scene->r.imtype==R_TIFF)) {
extension= ".tif";
if(!BLI_testextensie(string, ".tif"))
extension= ".tif";
}
#ifdef WITH_OPENEXR
else if(G.scene->r.imtype==R_OPENEXR) {
if(!BLI_testextensie(string, ".exr"))
extension= ".exr";
}
#endif
strcat(string, extension);
}
@@ -449,13 +456,13 @@ static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */
tbuf2 = IMB_allocImBuf(ibuf->x, (short)(ibuf->y >> 1), (unsigned char)32, (int)IB_rect, (unsigned char)0);
ibuf->x *= 2;
/* These rectop calls are broken!!! I added a trailing 0 arg... */
IMB_rectop(tbuf1, ibuf, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectop(tbuf2, ibuf, 0, 0, tbuf2->x, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y);
ibuf->x /= 2;
IMB_rectop(ibuf, tbuf1, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectop(ibuf, tbuf2, 0, tbuf2->y, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y);
IMB_rectcpy(ibuf, tbuf2, 0, tbuf2->y, 0, 0, tbuf2->x, tbuf2->y);
IMB_freeImBuf(tbuf1);
IMB_freeImBuf(tbuf2);
@@ -477,13 +484,13 @@ static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */
tbuf2 = IMB_allocImBuf(ibuf->x, (short)(ibuf->y >> 1), (unsigned char)32, IB_rect, 0);
ibuf->x *= 2;
/* These are brolenm as well... */
IMB_rectop(tbuf1, ibuf, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectop(tbuf2, ibuf, 0, 0, tbuf2->x, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y);
ibuf->x /= 2;
IMB_rectop(ibuf, tbuf2, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectop(ibuf, tbuf1, 0, tbuf2->y, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(ibuf, tbuf2, 0, 0, 0, 0, tbuf2->x, tbuf2->y);
IMB_rectcpy(ibuf, tbuf1, 0, tbuf2->y, 0, 0, tbuf1->x, tbuf1->y);
IMB_freeImBuf(tbuf1);
IMB_freeImBuf(tbuf2);
@@ -559,7 +566,7 @@ void ima_ibuf_is_nul(Tex *tex, Image *ima)
}
IMB_applycmap(ima->ibuf);
IMB_convert_rgba_to_abgr(ima->ibuf->x*ima->ibuf->y, ima->ibuf->rect);
IMB_convert_rgba_to_abgr(ima->ibuf);
}

View File

@@ -35,10 +35,6 @@
#include <string.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
@@ -122,7 +118,8 @@ void start_avi(void)
void append_avi(int frame)
{
unsigned int *rt1, *rt2, *temp;
unsigned int *rt1, *rt2;
struct ImBuf *temp;
int y;
if (avi == NULL) {
@@ -130,20 +127,20 @@ void append_avi(int frame)
return;
}
/* note that libavi free's the buffer... stupid interface - zr */
temp = MEM_mallocN(R.rectx*R.recty*4, "append_avi buf");
/* note that libavi free's the buffer... stupid interface - zr */
temp = IMB_allocImBuf(R.rectx,R.recty*4,32, IB_rect, 0);
rt1= temp;
rt1= temp->rect;
rt2= R.rectot + (R.recty-1)*R.rectx;
for (y=0; y < R.recty; y++, rt1+= R.rectx, rt2-= R.rectx) {
memcpy (rt1, rt2, R.rectx*4);
}
IMB_convert_rgba_to_abgr(R.rectx*R.recty, temp);
IMB_convert_rgba_to_abgr(temp);
AVI_write_frame (avi, (frame-sframe), AVI_FORMAT_RGB32,
temp, R.rectx*R.recty*4);
AVI_write_frame (avi, (frame-sframe), AVI_FORMAT_RGB32, temp->rect, R.rectx*R.recty*4);
printf ("added frame %3d (frame %3d in avi): ", frame, frame-sframe);
IMB_freeImBuf(temp);
}
void end_avi(void)

View File

@@ -139,6 +139,7 @@ int BLI_stringdec(char *string, char *kop, char *staart, unsigned short *numlen)
else if (BLI_strncasecmp(string + len - 4, ".rgb", 4) == 0) len -= 4;
else if (BLI_strncasecmp(string + len - 4, ".psx", 4) == 0) len -= 4;
else if (BLI_strncasecmp(string + len - 4, ".ble", 4) == 0) len -= 4;
else if (BLI_strncasecmp(string + len - 4, ".exr", 4) == 0) len -= 4;
}
}

View File

@@ -44,10 +44,16 @@
#define IB_zbuf (1 << 13)
#define IB_rgba (1 << 14)
#define AMI (1 << 31)
#define Anim (1 << 29)
#define TGA (1 << 28)
#define JPG (1 << 27)
#define AMI (1 << 31)
#define PNG (1 << 30)
#define Anim (1 << 29)
#define TGA (1 << 28)
#define JPG (1 << 27)
#define BMP (1 << 26)
#ifdef WITH_QUICKTIME
#define QUICKTIME (1 << 25)
#endif
#define RADHDR (1<<24)
#define RAWTGA (TGA | 1)
@@ -90,6 +96,7 @@
#define IS_amiga(x) (x->ftype & AMI)
#define IS_ham(x) ((x->ftype & AM_ham) == AM_ham)
#define IS_hbrite(x) ((x->ftype & AM_hbrite) == AM_hbrite)
#define IS_lace(x) ((x->ftype & AM_lace) == AM_lace)
#define IS_hires(x) ((x->ftype & AM_hires) == AM_hires)
#define IS_hblace(x) ((x->ftype & AM_hblace) == AM_hblace)
@@ -98,9 +105,14 @@
#define IS_anim(x) (x->ftype & Anim)
#define IS_hamx(x) (x->ftype == AN_hamx)
#define IS_tga(x) (x->ftype & TGA)
#define IS_png(x) (x->ftype & PNG)
#define IS_bmp(x) (x->ftype & BMP)
#define IS_radhdr(x) (x->ftype & RADHDR)
#define IS_tim(x) (x->ftype & TIM)
#define IS_tiff(x) (x->ftype & TIFF)
#define IS_openexr(x) (x->ftype & OPENEXR)
#define IMAGIC 0732
#define IS_iris(x) (x->ftype == IMAGIC)
@@ -136,6 +148,7 @@ typedef struct ImBuf{
unsigned char *encodedbuffer;
unsigned int encodedsize;
unsigned int encodedbuffersize;
float *rect_float;
} ImBuf;
extern struct ImBuf *allocImBuf(short,short,uchar,uint,uchar);

View File

@@ -41,10 +41,6 @@
* - util.h : Useful defines, memory management.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef WIN32
#include "blenpluginapi\util.h"
#else
@@ -250,20 +246,6 @@ void de_interlace(struct ImBuf *ib)
IMB_de_interlace(ib);
}
void rectop(struct ImBuf *dbuf,
struct ImBuf *sbuf,
int destx,
int desty,
int srcx,
int srcy,
int width,
int height,
void (*operation)(unsigned int *, unsigned int*, int, int),
int value)
{
IMB_rectop(dbuf, sbuf, destx, desty, srcx, srcy, width, height, operation, value);
}
/* -------------------------------------------------------------------------- */
/* stuff from plugin.h */
/* -------------------------------------------------------------------------- */
@@ -354,6 +336,5 @@ int pluginapi_force_ref(void)
(int) turbulence1 +
(int) de_interlace +
(int) interlace +
(int) gamwarp +
(int) rectop;
(int) gamwarp;
}

View File

@@ -196,31 +196,8 @@ void IMB_freecmapImBuf(struct ImBuf * ibuf);
*
* @attention Defined in rectop.c
*/
void IMB_rectop(struct ImBuf *dbuf,
struct ImBuf *sbuf,
int destx,
int desty,
int srcx,
int srcy,
int width,
int height,
void (*operation)(unsigned int *, unsigned int*, int, int),
int value);
/**
*
* @attention Defined in rectop.c
*/
void IMB_rectoptot(struct ImBuf *dbuf,
struct ImBuf *sbuf,
void (*operation)(unsigned int *, unsigned int*, int, int),
int value);
/**
*
* @attention Defined in rectop.c
*/
void IMB_rectcpy(unsigned int *drect, unsigned int *srect, int x, int dummy);
void IMB_rectcpy(struct ImBuf *drect, struct ImBuf *srect, int destx,
int desty, int srcx, int srcy, int width, int height);
/**
* Return the length (in frames) of the given @a anim.
@@ -360,7 +337,7 @@ void IMB_gamwarp(struct ImBuf *ibuf, double gamma);
*
* @attention Defined in imageprocess.c
*/
void IMB_convert_rgba_to_abgr(int size, unsigned int *rect);
void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf);
/**
* Change the ordering of the colour bytes pointed to by rect from
@@ -495,7 +472,7 @@ void IMB_freezbufImBuf(struct ImBuf * ibuf);
*
* @attention Defined in rectop.c
*/
void IMB_rectfill(unsigned int *drect, unsigned int *srect, int x, int value);
void IMB_rectfill(struct ImBuf *drect, float col[4]);
#ifdef WITH_QUICKTIME
@@ -513,12 +490,6 @@ void quicktime_exit(void);
#endif //WITH_QUICKTIME
/* radhdr: Temporary routine to save directly from render floatbuffer.
Defined in radiance_hdr.c
Called by schrijfplaatje() in toets.c */
short imb_savehdr_fromfloat(float *fbuf, char *name, int width, int height);
/* intern/dynlibtiff.c */
void libtiff_exit(void);

View File

@@ -93,6 +93,7 @@ typedef struct ImBuf{
unsigned char *encodedbuffer; /**< Compressed image only used with png currently */
unsigned int encodedsize; /**< Size of data written to encodedbuffer */
unsigned int encodedbuffersize; /**< Size of encodedbuffer */
float *rect_float; /**< floating point Rect equivilant */
} ImBuf;
/* Moved from BKE_bmfont_types.h because it is a userflag bit mask. */
@@ -131,6 +132,8 @@ typedef enum {
#define IB_zbuf (1 << 13)
#define IB_mem (1 << 14)
#define IB_rectfloat (1 << 15)
/**@}*/
/** \name imbuf_formats Image file formats
@@ -141,17 +144,20 @@ typedef enum {
*
* The bit flag is stored in the ImBuf.ftype variable.
*/
#define AMI (1 << 31)
#define PNG (1 << 30)
#define AMI (1 << 31)
#define PNG (1 << 30)
#define Anim (1 << 29)
#define TGA (1 << 28)
#define JPG (1 << 27)
#define BMP (1 << 26)
#define TGA (1 << 28)
#define JPG (1 << 27)
#define BMP (1 << 26)
#ifdef WITH_QUICKTIME
#define QUICKTIME (1 << 25)
#define QUICKTIME (1 << 25)
#endif
#define RADHDR (1<<24)
#define TIF (1<<23)
#define RADHDR (1 << 24)
#define TIF (1 << 23)
#define OPENEXR (1 << 22)
#define RAWTGA (TGA | 1)
@@ -188,6 +194,7 @@ typedef enum {
#define IS_hamx(x) (x->ftype == AN_hamx)
#define IS_tga(x) (x->ftype & TGA)
#define IS_png(x) (x->ftype & PNG)
#define IS_openexr(x) (x->ftype & OPENEXR)
#define IS_bmp(x) (x->ftype & BMP)
#define IS_tiff(x) (x->ftype & TIF)
#define IS_radhdr(x) (x->ftype & RADHDR)

View File

@@ -5,6 +5,9 @@ Import ('library_env')
imbuf_env = library_env.Copy ()
#if user_options_dict['USE_OPENEXR'] == 1:
# SConscript (['intern/openexr/SConscript'])
source_files = ['intern/allocimbuf.c',
'intern/amiga.c',
'intern/anim.c',

View File

@@ -43,12 +43,14 @@
struct ImBuf;
short imb_addrectImBuf(struct ImBuf * ibuf);
short imb_addrectfloatImBuf(struct ImBuf * ibuf);
short imb_addplanesImBuf(struct ImBuf *ibuf);
short imb_addencodedbufferImBuf(struct ImBuf *ibuf);
short imb_enlargeencodedbufferImBuf(struct ImBuf *ibuf);
void imb_freerectImBuf(struct ImBuf *ibuf);
void imb_freerectfloatImBuf(struct ImBuf *ibuf);
void imb_freeplanesImBuf(struct ImBuf *ibuf);
short imb_addcmapImBuf(struct ImBuf *ibuf);

View File

@@ -33,13 +33,25 @@
LIBNAME = imbuf
DIR = $(OCGDIR)/blender/imbuf
SOURCEDIR = source/blender/imbuf/intern
include nan_subdirs.mk
include nan_compile.mk
include nan_definitions.mk
ifeq ($(WITH_OPENEXR), true)
DIRS = openexr
endif
ifeq ($(OS),$(findstring $(OS), "beos darwin freebsd linux openbsd solaris windows"))
CFLAGS += -funsigned-char
endif
ifeq ($(WITH_OPENEXR), true)
CFLAGS += -DWITH_OPENEXR
endif
CFLAGS += $(LEVEL_1_C_WARNINGS)
CPPFLAGS += -I$(NAN_JPEG)/include

View File

@@ -53,30 +53,48 @@ static unsigned int dfltcmap[16] = {
void imb_freeplanesImBuf(struct ImBuf * ibuf)
{
if (ibuf==0) return;
if (ibuf==NULL) return;
if (ibuf->planes){
if (ibuf->mall & IB_planes) free(ibuf->planes);
if (ibuf->mall & IB_planes) MEM_freeN(ibuf->planes);
}
ibuf->planes = 0;
ibuf->mall &= ~IB_planes;
}
void imb_freerectfloatImBuf(struct ImBuf * ibuf)
{
if (ibuf==NULL) return;
if (ibuf->rect_float) {
if (ibuf->mall & IB_rectfloat) {
MEM_freeN(ibuf->rect_float);
ibuf->rect_float=NULL;
}
}
ibuf->rect_float= NULL;
ibuf->mall &= ~IB_rectfloat;
}
void imb_freerectImBuf(struct ImBuf * ibuf)
{
if (ibuf==0) return;
if (ibuf->rect){
if (ibuf->mall & IB_rect) free(ibuf->rect);
if (ibuf==NULL) return;
if (ibuf->rect) {
if (ibuf->mall & IB_rect) {
MEM_freeN(ibuf->rect);
}
}
ibuf->rect=0;
ibuf->rect= NULL;
ibuf->mall &= ~IB_rect;
}
static void freeencodedbufferImBuf(struct ImBuf * ibuf)
{
if (ibuf==0) return;
if (ibuf==NULL) return;
if (ibuf->encodedbuffer){
if (ibuf->mall & IB_mem) free(ibuf->encodedbuffer);
if (ibuf->mall & IB_mem) MEM_freeN(ibuf->encodedbuffer);
}
ibuf->encodedbuffer = 0;
ibuf->encodedbuffersize = 0;
@@ -86,34 +104,34 @@ static void freeencodedbufferImBuf(struct ImBuf * ibuf)
void IMB_freezbufImBuf(struct ImBuf * ibuf)
{
if (ibuf==0) return;
if (ibuf==NULL) return;
if (ibuf->zbuf){
if (ibuf->mall & IB_zbuf) free(ibuf->zbuf);
if (ibuf->mall & IB_zbuf) MEM_freeN(ibuf->zbuf);
}
ibuf->zbuf=0;
ibuf->zbuf= NULL;
ibuf->mall &= ~IB_zbuf;
}
void IMB_freecmapImBuf(struct ImBuf * ibuf)
{
if (ibuf == 0) return;
if (ibuf==NULL) return;
if (ibuf->cmap){
if (ibuf->mall & IB_cmap) free(ibuf->cmap);
if (ibuf->mall & IB_cmap) MEM_freeN(ibuf->cmap);
}
ibuf->cmap = 0;
ibuf->mall &= ~IB_cmap;
}
void IMB_freeImBuf(struct ImBuf * ibuf)
{
if (ibuf){
imb_freeplanesImBuf(ibuf);
imb_freerectImBuf(ibuf);
imb_freerectfloatImBuf(ibuf);
IMB_freezbufImBuf(ibuf);
IMB_freecmapImBuf(ibuf);
freeencodedbufferImBuf(ibuf);
free(ibuf);
MEM_freeN(ibuf);
}
}
@@ -121,7 +139,8 @@ short addzbufImBuf(struct ImBuf * ibuf)
{
int size;
if (ibuf==0) return(FALSE);
if (ibuf==NULL) return(FALSE);
IMB_freezbufImBuf(ibuf);
size = ibuf->x * ibuf->y * sizeof(unsigned int);
@@ -136,7 +155,7 @@ short addzbufImBuf(struct ImBuf * ibuf)
short imb_addencodedbufferImBuf(struct ImBuf * ibuf)
{
if (ibuf==0) return(FALSE);
if (ibuf==NULL) return(FALSE);
freeencodedbufferImBuf(ibuf);
@@ -159,7 +178,7 @@ short imb_enlargeencodedbufferImBuf(struct ImBuf * ibuf)
unsigned int newsize, encodedsize;
void *newbuffer;
if (ibuf==0) return(FALSE);
if (ibuf==NULL) return(FALSE);
if (ibuf->encodedbuffersize < ibuf->encodedsize) {
printf("imb_enlargeencodedbufferImBuf: error in parameters\n");
@@ -190,15 +209,36 @@ short imb_enlargeencodedbufferImBuf(struct ImBuf * ibuf)
return (TRUE);
}
short imb_addrectfloatImBuf(struct ImBuf * ibuf)
{
int size;
if (ibuf==NULL) return(FALSE);
imb_freerectfloatImBuf(ibuf);
size = ibuf->x * ibuf->y;
size = size * 4 * sizeof(float);
if ( (ibuf->rect_float = MEM_mallocN(size, "imb_addrectImBuf")) ){
ibuf->mall |= IB_rectfloat;
return (TRUE);
}
return (FALSE);
}
/* question; why also add zbuf? */
short imb_addrectImBuf(struct ImBuf * ibuf)
{
int size;
if (ibuf==0) return(FALSE);
if (ibuf==NULL) return(FALSE);
imb_freerectImBuf(ibuf);
size = ibuf->x * ibuf->y * sizeof(unsigned int);
size = ibuf->x * ibuf->y;
size = size * sizeof(unsigned int);
if ( (ibuf->rect = MEM_mallocN(size, "imb_addrectImBuf")) ){
ibuf->mall |= IB_rect;
if (ibuf->depth > 32) return (addzbufImBuf(ibuf));
@@ -213,7 +253,7 @@ short imb_addcmapImBuf(struct ImBuf *ibuf)
{
int min;
if (ibuf==0) return(FALSE);
if (ibuf==NULL) return(FALSE);
IMB_freecmapImBuf(ibuf);
imb_checkncols(ibuf);
@@ -238,7 +278,7 @@ short imb_addplanesImBuf(struct ImBuf *ibuf)
unsigned int **planes;
unsigned int *point2;
if (ibuf==0) return(FALSE);
if (ibuf==NULL) return(FALSE);
imb_freeplanesImBuf(ibuf);
skipx = ((ibuf->x+31) >> 5);
@@ -264,7 +304,7 @@ short imb_addplanesImBuf(struct ImBuf *ibuf)
}
struct ImBuf *IMB_allocImBuf(short x,short y,uchar d,unsigned int flags,uchar bitmap)
struct ImBuf *IMB_allocImBuf(short x, short y, uchar d, unsigned int flags, uchar bitmap)
{
struct ImBuf *ibuf;
@@ -272,29 +312,36 @@ struct ImBuf *IMB_allocImBuf(short x,short y,uchar d,unsigned int flags,uchar bi
if (bitmap) flags |= IB_planes;
if (ibuf){
ibuf->x=x;
ibuf->y=y;
ibuf->depth=d;
ibuf->ftype=TGA;
ibuf->x= x;
ibuf->y= y;
ibuf->depth= d;
ibuf->ftype= TGA;
if (flags & IB_rect){
if (imb_addrectImBuf(ibuf)==FALSE){
IMB_freeImBuf(ibuf);
return (0);
return NULL;
}
}
if (flags & IB_rectfloat){
if (imb_addrectfloatImBuf(ibuf)==FALSE){
IMB_freeImBuf(ibuf);
return NULL;
}
}
if (flags & IB_zbuf){
if (addzbufImBuf(ibuf)==FALSE){
IMB_freeImBuf(ibuf);
return (0);
return NULL;
}
}
if (flags & IB_planes){
if (imb_addplanesImBuf(ibuf)==FALSE){
IMB_freeImBuf(ibuf);
return (0);
return NULL;
}
}
}
@@ -307,9 +354,10 @@ struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1)
int flags = 0;
int x, y;
if (ibuf1 == 0) return (0);
if (ibuf1 == NULL) return NULL;
if (ibuf1->rect) flags |= IB_rect;
if (ibuf1->rect_float) flags |= IB_rectfloat;
if (ibuf1->planes) flags |= IB_planes;
x = ibuf1->x;
@@ -317,31 +365,38 @@ struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1)
if (ibuf1->flags & IB_fields) y *= 2;
ibuf2 = IMB_allocImBuf(x, y, ibuf1->depth, flags, 0);
if (ibuf2 == 0) return (0);
if (ibuf2 == NULL) return NULL;
if (flags & IB_rect) memcpy(ibuf2->rect,ibuf1->rect,x * y * sizeof(int));
if (flags & IB_planes) memcpy(*(ibuf2->planes),*(ibuf1->planes),ibuf1->depth * ibuf1->skipx * y * sizeof(int));
if (flags & IB_rect)
memcpy(ibuf2->rect, ibuf1->rect, x * y * sizeof(int));
if (flags & IB_rectfloat)
memcpy(ibuf2->rect_float, ibuf1->rect_float, x * y * sizeof(float));
if (flags & IB_planes)
memcpy(*(ibuf2->planes),*(ibuf1->planes),ibuf1->depth * ibuf1->skipx * y * sizeof(int));
if (ibuf1->encodedbuffer) {
ibuf2->encodedbuffersize = ibuf1->encodedbuffersize;
if (imb_addencodedbufferImBuf(ibuf2) == FALSE) {
IMB_freeImBuf(ibuf2);
return(0);
return NULL;
}
memcpy(ibuf2->encodedbuffer, ibuf1->encodedbuffer, ibuf1->encodedsize);
}
/* silly trick to copy the entire contents of ibuf1 struct over to ibuf */
tbuf = *ibuf1;
// pointers goedzetten
// fix pointers
tbuf.rect = ibuf2->rect;
tbuf.rect_float = ibuf2->rect_float;
tbuf.planes = ibuf2->planes;
tbuf.cmap = ibuf2->cmap;
tbuf.encodedbuffer = ibuf2->encodedbuffer;
// malloc flag goed zetten
// set malloc flag
tbuf.mall = ibuf2->mall;
*ibuf2 = tbuf;

View File

@@ -531,7 +531,7 @@ struct ImBuf *imb_loadamiga(int *iffmem,int flags)
if (ibuf) {
if (ibuf->rect)
if (G.order == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf->x*ibuf->y, ibuf->rect);
if (G.order == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
}
return (ibuf);

View File

@@ -572,7 +572,7 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position) {
ibuf = movie_fetchibuf(anim, position);
if (ibuf) {
anim->curposition = position;
IMB_convert_rgba_to_abgr(ibuf->x*ibuf->y, ibuf->rect);
IMB_convert_rgba_to_abgr(ibuf);
}
break;
case ANIM_AVI:

View File

@@ -161,7 +161,7 @@ static void planes_to_rect(struct ImBuf * ibuf, int flags) {
if (ibuf->cmap){
if ((flags & IB_cmap) == 0) {
IMB_applycmap(ibuf);
IMB_convert_rgba_to_abgr(ibuf->x*ibuf->y, ibuf->rect);
IMB_convert_rgba_to_abgr(ibuf);
}
} else if (ibuf->depth == 18){
int i,col;

View File

@@ -178,6 +178,8 @@ void imb_bptolong(struct ImBuf *ibuf)
{
int nobp,i,x;
unsigned int *rect,offset;
float black[4] = {0.0,0.0,0.0,1.0};
float clear[4] = {0.0,0.0,0.0,0.0};
/* first clear all ints */
@@ -187,8 +189,8 @@ void imb_bptolong(struct ImBuf *ibuf)
nobp=ibuf->depth;
if (nobp != 32){
if (nobp == 24) IMB_rectoptot(ibuf, 0, IMB_rectfill, 0xff000000); /* set alpha */
else IMB_rectoptot(ibuf, 0, IMB_rectfill, 0);
if (nobp == 24) IMB_rectfill(ibuf, black); /* set alpha */
else IMB_rectfill(ibuf, clear);
}
rect= ibuf->rect;

View File

@@ -95,12 +95,12 @@ void IMB_de_interlace(struct ImBuf *ibuf)
tbuf2 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect, 0);
ibuf->x *= 2;
IMB_rectop(tbuf1, ibuf, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectop(tbuf2, ibuf, 0, 0, tbuf2->x, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y);
ibuf->x /= 2;
IMB_rectop(ibuf, tbuf1, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectop(ibuf, tbuf2, 0, tbuf2->y, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y);
IMB_rectcpy(ibuf, tbuf2, 0, tbuf2->y, 0, 0, tbuf2->x, tbuf2->y);
IMB_freeImBuf(tbuf1);
IMB_freeImBuf(tbuf2);
@@ -122,16 +122,12 @@ void IMB_interlace(struct ImBuf *ibuf)
tbuf1 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect, 0);
tbuf2 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect, 0);
IMB_rectop(tbuf1, ibuf, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy,
0);
IMB_rectop(tbuf2, ibuf, 0, 0, 0, tbuf2->y, 32767, 32767,
IMB_rectcpy,0);
IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
IMB_rectcpy(tbuf2, ibuf, 0, 0, 0, tbuf2->y, ibuf->x, ibuf->y);
ibuf->x *= 2;
IMB_rectop(ibuf, tbuf1, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy,
0);
IMB_rectop(ibuf, tbuf2, tbuf2->x, 0, 0, 0, 32767, 32767,
IMB_rectcpy,0);
IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y);
IMB_rectcpy(ibuf, tbuf2, tbuf2->x, 0, 0, 0, tbuf2->x, tbuf2->y);
ibuf->x /= 2;
IMB_freeImBuf(tbuf1);
@@ -143,11 +139,13 @@ void IMB_interlace(struct ImBuf *ibuf)
void IMB_gamwarp(struct ImBuf *ibuf, double gamma)
{
uchar gam[256];
int i;
uchar *rect;
int i, do_float=0;
uchar *rect = (uchar *) ibuf->rect;
float *rectf = ibuf->rect_float;
if (ibuf == 0) return;
if (ibuf->rect == 0) return;
if (ibuf->rect != NULL) do_float = 1;
if (gamma == 1.0) return;
gamma = 1.0 / gamma;
@@ -159,5 +157,10 @@ void IMB_gamwarp(struct ImBuf *ibuf, double gamma)
rect[0] = gam[rect[0]];
rect[1] = gam[rect[1]];
rect[2] = gam[rect[2]];
if (do_float) {
rectf[0] = pow(rectf[0] / 255.0, gamma);
rectf[1] = pow(rectf[1] / 255.0, gamma);
rectf[2] = pow(rectf[2] / 255.0, gamma);
}
}
}

View File

@@ -65,6 +65,26 @@ static void filtrow(unsigned char *point, int x)
}
}
static void filtrowf(float *point, int x)
{
float c1,c2,c3,error;
if (x>1){
c1 = c2 = *point;
error = 2;
for(x--;x>0;x--){
c3 = point[4];
c1 += (c2 * 2) + c3 + error;
*point = c1 / 4.0;
point += 4;
c1=c2;
c2=c3;
}
*point = (c1 + (c2 * 2) + c2 + error) / 4.0;
}
}
static void filtcolum(unsigned char *point, int y, int skip)
{
@@ -89,13 +109,38 @@ static void filtcolum(unsigned char *point, int y, int skip)
}
}
static void filtcolumf(float *point, int y, int skip)
{
float c1,c2,c3,error, *point2;
if (y>1){
c1 = c2 = *point;
point2 = point;
error = 2;
for(y--;y>0;y--){
point2 += skip;
c3 = *point2;
c1 += (c2 * 2) + c3 +error;
*point = c1 / 4;
point=point2;
c1=c2;
c2=c3;
}
*point = (c1 + (c2 * 2) + c2 + error) / 4;
}
}
void IMB_filtery(struct ImBuf *ibuf)
{
unsigned char *point;
int x, y, skip;
float *pointf;
int x, y, skip, do_float = 0;
point = (unsigned char *)ibuf->rect;
pointf = ibuf->rect_float;
if (ibuf->rect_float != NULL) do_float = 1;
x = ibuf->x;
y = ibuf->y;
skip = x<<2;
@@ -109,6 +154,16 @@ void IMB_filtery(struct ImBuf *ibuf)
point++;
filtcolum(point,y,skip);
point++;
if (do_float) {
if (ibuf->depth > 24) filtcolumf(pointf,y,skip);
pointf++;
filtcolumf(pointf,y,skip);
pointf++;
filtcolumf(pointf,y,skip);
pointf++;
filtcolumf(pointf,y,skip);
point++;
}
}
}
@@ -116,9 +171,14 @@ void IMB_filtery(struct ImBuf *ibuf)
void imb_filterx(struct ImBuf *ibuf)
{
unsigned char *point;
int x, y, skip;
float *pointf;
int x, y, skip, do_float =0;
point = (unsigned char *)ibuf->rect;
pointf = ibuf->rect_float;
if (ibuf->rect_float != NULL) do_float = 1;
x = ibuf->x;
y = ibuf->y;
skip = (x<<2) - 3;
@@ -132,6 +192,16 @@ void imb_filterx(struct ImBuf *ibuf)
point++;
filtrow(point,x);
point+=skip;
if (do_float) {
if (ibuf->depth > 24) filtrowf(pointf,x);
pointf++;
filtrowf(pointf,x);
pointf++;
filtrowf(pointf,x);
pointf++;
filtrowf(pointf,x);
pointf+=skip;
}
}
}

View File

@@ -40,13 +40,19 @@
* $Id$
*/
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
/* Only this one is used liberally here, and in imbuf */
void IMB_convert_rgba_to_abgr(int size, unsigned int *rect)
void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf)
{
char *cp= (char *)rect, rt;
int size, do_float=0;
unsigned char rt, *cp = (unsigned char *)ibuf->rect;
float rtf, *cpf = ibuf->rect_float;
if (ibuf->rect_float) do_float = 1;
size = ibuf->x * ibuf->y;
while(size-- > 0) {
rt= cp[0];
cp[0]= cp[3];
@@ -55,5 +61,15 @@ void IMB_convert_rgba_to_abgr(int size, unsigned int *rect)
cp[1]= cp[2];
cp[2]= rt;
cp+= 4;
if (do_float) {
rtf= cpf[0];
cpf[0]= cpf[3];
cpf[3]= rtf;
rtf= cpf[1];
cpf[1]= cpf[2];
cpf[2]= rtf;
cpf+= 4;
}
}
}

View File

@@ -398,7 +398,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, int flags)
if (ibuf) {
if (ibuf->rect)
IMB_convert_rgba_to_abgr(ibuf->x*ibuf->y, ibuf->rect);
IMB_convert_rgba_to_abgr(ibuf);
}
return(ibuf);
@@ -639,13 +639,13 @@ short imb_saveiris(struct ImBuf * ibuf, char *name, int flags)
zsize = (ibuf->depth + 7) >> 3;
if (flags & IB_zbuf && ibuf->zbuf != 0) zsize = 8;
IMB_convert_rgba_to_abgr(ibuf->x*ibuf->y, ibuf->rect);
IMB_convert_rgba_to_abgr(ibuf);
test_endian_zbuf(ibuf);
ret = output_iris(ibuf->rect, ibuf->x, ibuf->y, zsize, name, ibuf->zbuf);
/* restore! Quite clumsy, 2 times a switch... maybe better a malloc ? */
IMB_convert_rgba_to_abgr(ibuf->x*ibuf->y, ibuf->rect);
IMB_convert_rgba_to_abgr(ibuf);
test_endian_zbuf(ibuf);
return(ret);

View File

@@ -553,15 +553,12 @@ static int save_jstjpeg(char * name, struct ImBuf * ibuf)
ibuf->x *= 2;
ibuf->y /= 2;
/* extra argument assumed to be 0 (nzc) */
IMB_rectop(tbuf, ibuf, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(tbuf, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
sprintf(fieldname, "%s.jf0", name);
returnval = save_vidjpeg(fieldname, tbuf) ;
if (returnval == 1) {
/* extra argument assumed to be 0 (nzc) */
IMB_rectop(tbuf, ibuf, 0, 0, tbuf->x, 0, 32767, 32767,
IMB_rectcpy, 0);
IMB_rectcpy(tbuf, ibuf, 0, 0, tbuf->x, 0, ibuf->x, ibuf->y);
sprintf(fieldname, "%s.jf1", name);
returnval = save_vidjpeg(fieldname, tbuf);
}

View File

@@ -0,0 +1,51 @@
#
# $Id$
#
# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. The Blender
# Foundation also sells licenses for use in proprietary software under
# the Blender License. See http://www.blender.org/BL/ for information
# about this.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Gernot Ziegler <gz@lysator.liu.se>
#
# ***** END GPL/BL DUAL LICENSE BLOCK *****
#
#
LIBNAME = openexr
DIR = $(OCGDIR)/blender/imbuf/openexr
include nan_compile.mk
ifeq ($(OS),$(findstring $(OS), "beos darwin freebsd linux openbsd solaris windows"))
CFLAGS += -funsigned-char
endif
CFLAGS += $(LEVEL_1_C_WARNINGS)
CPPFLAGS += -I../../../makesdna
CPPFLAGS += -I../../../blenkernel
CPPFLAGS += -I../../../blenlib
CPPFLAGS += -I../../../imbuf
CPPFLAGS += -I../../../imbuf/intern
CPPFLAGS += $(NAN_OPENEXR_INC)
CPPFLAGS += -I.

View File

@@ -0,0 +1,22 @@
#!/usr/bin/python
Import ('extra_includes')
Import ('user_options_dict')
Import ('library_env')
openexr_env = library_env.Copy ()
source_files = ['openexr_api.cpp'
]
include_paths = ['.',
'../blenkernel',
'../imbuf',
'../imbuf/intern',
'../blenlib',
'../makesdna']
openexr_env.Append(CPPPATH = extra_includes)
openexr_env.Append(CPPPATH = include_paths)
openexr_env.Prepend (CPPPATH = user_options_dict['OPENEXR_INCLUDE'])
#ftf_env.Append(CPPDEFINES = 'FTGL_STATIC_LIBRARY')
openexr_env.Library (target='#'+user_options_dict['BUILD_DIR']+'/lib/blender_openexr', source=source_files)

View File

@@ -0,0 +1,441 @@
/**
*
* ***** BEGIN GPLLICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Copyright by Gernot Ziegler <gz@lysator.liu.se>.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Austin Benesh, Ton Roosendaal (float, half, speedup, cleanup...).
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <openexr_api.h>
extern "C"
{
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "IMB_allocimbuf.h"
#include "BKE_global.h"
#include "DNA_scene_types.h"
}
#include <iostream>
#include <OpenEXR/half.h>
#include <OpenEXR/ImfVersion.h>
#include <OpenEXR/ImathBox.h>
#include <OpenEXR/ImfArray.h>
#include <OpenEXR/ImfIO.h>
#include <OpenEXR/ImfChannelList.h>
#include <OpenEXR/ImfPixelType.h>
#include <OpenEXR/ImfInputFile.h>
#include <OpenEXR/ImfOutputFile.h>
#include <OpenEXR/ImfCompression.h>
#include <OpenEXR/ImfCompressionAttribute.h>
using namespace Imf;
using namespace Imath;
class Mem_IStream: public IStream
{
public:
Mem_IStream (unsigned char *exrbuf, int exrsize):
IStream("dummy"), _exrpos (0), _exrsize(exrsize) { _exrbuf = exrbuf; }
virtual bool read (char c[], int n);
virtual Int64 tellg ();
virtual void seekg (Int64 pos);
virtual void clear ();
//virtual ~Mem_IStream() {}; // unused
private:
Int64 _exrpos;
Int64 _exrsize;
unsigned char *_exrbuf;
};
bool Mem_IStream::read (char c[], int n)
{
if (n + _exrpos <= _exrsize)
{
memcpy(c, (void *)(&_exrbuf[_exrpos]), n);
_exrpos += n;
return true;
}
else
return false;
}
Int64 Mem_IStream::tellg ()
{
return _exrpos;
}
void Mem_IStream::seekg (Int64 pos)
{
_exrpos = pos;
}
void Mem_IStream::clear ()
{
}
struct _RGBAZ
{
half r;
half g;
half b;
half a;
half z;
};
typedef struct _RGBAZ RGBAZ;
extern "C"
{
int imb_is_a_openexr(unsigned char *mem)
{
return Imf::isImfMagic ((const char *)mem);
}
static void openexr_header_compression(Header *header, int compression)
{
switch(compression)
{
case 0:
header->compression() = NO_COMPRESSION;
break;
case 1:
header->compression() = PXR24_COMPRESSION;
break;
case 2:
header->compression() = ZIP_COMPRESSION;
break;
case 3:
header->compression() = PIZ_COMPRESSION;
break;
case 4:
header->compression() = RLE_COMPRESSION;
break;
default:
header->compression() = NO_COMPRESSION;
break;
}
}
short imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags)
{
int width = ibuf->x;
int height = ibuf->y;
if (flags & IB_mem)
{
printf("OpenEXR-save: Create EXR in memory CURRENTLY NOT SUPPORTED !\n");
imb_addencodedbufferImBuf(ibuf);
ibuf->encodedsize = 0;
return(0);
}
int write_zbuf = (flags & IB_zbuf) && ibuf->zbuf != NULL; // summarize
try
{
Header header (width, height);
openexr_header_compression(&header, G.scene->r.quality);
header.channels().insert ("R", Channel (HALF));
header.channels().insert ("G", Channel (HALF));
header.channels().insert ("B", Channel (HALF));
header.channels().insert ("A", Channel (HALF));
if (write_zbuf) // z we do as uint always
header.channels().insert ("Z", Channel (UINT));
FrameBuffer frameBuffer;
OutputFile *file = new OutputFile(name, header);
/* we store first everything in half array */
RGBAZ *pixels = new RGBAZ[height * width];
RGBAZ *to = pixels;
int xstride= sizeof (RGBAZ);
int ystride= xstride*width;
/* indicate used buffers */
frameBuffer.insert ("R", Slice (HALF, (char *) &pixels[0].r, xstride, ystride));
frameBuffer.insert ("G", Slice (HALF, (char *) &pixels[0].g, xstride, ystride));
frameBuffer.insert ("B", Slice (HALF, (char *) &pixels[0].b, xstride, ystride));
frameBuffer.insert ("A", Slice (HALF, (char *) &pixels[0].a, xstride, ystride));
if (write_zbuf)
frameBuffer.insert ("Z", Slice (UINT, (char *) ibuf->zbuf + 4*(height-1)*width,
sizeof(int), sizeof(int) * -width));
if(ibuf->rect_float) {
float *from;
for (int i = ibuf->y-1; i >= 0; i--)
{
from= ibuf->rect_float + 4*i*width;
for (int j = ibuf->x; j > 0; j--)
{
to->r = from[0];
to->g = from[1];
to->b = from[2];
to->a = from[3];
to++; from += 4;
}
}
}
else {
unsigned char *from;
for (int i = ibuf->y-1; i >= 0; i--)
{
from= (unsigned char *)(ibuf->rect + i*width);
for (int j = ibuf->x; j > 0; j--)
{
to->r = (float)(from[0])/255.0;
to->g = (float)(from[1])/255.0;
to->b = (float)(from[2])/255.0;
to->a = (float)(from[3])/255.0;
to++; from += 4;
}
}
}
// printf("OpenEXR-save: Writing OpenEXR file of height %d.\n", height);
file->setFrameBuffer (frameBuffer);
file->writePixels (height);
delete file;
}
catch (const std::exception &exc)
{
printf("OpenEXR-save: ERROR: %s\n", exc.what());
if (ibuf) IMB_freeImBuf(ibuf);
return (0);
}
return (1);
}
short imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags)
{
int width = ibuf->x;
int height = ibuf->y;
if (flags & IB_mem)
{
printf("OpenEXR-save: Create EXR in memory CURRENTLY NOT SUPPORTED !\n");
imb_addencodedbufferImBuf(ibuf);
ibuf->encodedsize = 0;
return(0);
}
if (ibuf->rect_float==NULL)
return(0);
int write_zbuf = (flags & IB_zbuf) && ibuf->zbuf != NULL; // summarize
try
{
Header header (width, height);
openexr_header_compression(&header, G.scene->r.quality);
header.channels().insert ("R", Channel (FLOAT));
header.channels().insert ("G", Channel (FLOAT));
header.channels().insert ("B", Channel (FLOAT));
header.channels().insert ("A", Channel (FLOAT));
if (write_zbuf)
header.channels().insert ("Z", Channel (UINT));
FrameBuffer frameBuffer;
OutputFile *file = new OutputFile(name, header);
float *first= ibuf->rect_float + 4*(height-1)*width;
int xstride = sizeof(float) * 4;
int ystride = - xstride*width;
frameBuffer.insert ("R", Slice (FLOAT, (char *) first, xstride, ystride));
frameBuffer.insert ("G", Slice (FLOAT, (char *) (first+1), xstride, ystride));
frameBuffer.insert ("B", Slice (FLOAT, (char *) (first+2), xstride, ystride));
frameBuffer.insert ("A", Slice (FLOAT, (char *) (first+3), xstride, ystride));
if (write_zbuf)
frameBuffer.insert ("Z", Slice (UINT, (char *) ibuf->zbuf + 4*(height-1)*width,
sizeof(int), sizeof(int) * -width));
file->setFrameBuffer (frameBuffer);
file->writePixels (height);
delete file;
}
catch (const std::exception &exc)
{
printf("OpenEXR-save: ERROR: %s\n", exc.what());
if (ibuf) IMB_freeImBuf(ibuf);
return (0);
}
return (1);
// printf("OpenEXR-save: Done.\n");
}
struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags)
{
struct ImBuf *ibuf = 0;
InputFile *file = NULL;
// printf("OpenEXR-load: testing input, size is %d\n", size);
if (imb_is_a_openexr(mem) == 0) return(NULL);
try
{
// printf("OpenEXR-load: Creating InputFile from mem source\n");
Mem_IStream membuf(mem, size);
file = new InputFile(membuf);
Box2i dw = file->header().dataWindow();
int width = dw.max.x - dw.min.x + 1;
int height = dw.max.y - dw.min.y + 1;
// printf("OpenEXR-load: image data window %d %d %d %d\n",
// dw.min.x, dw.min.y, dw.max.x, dw.max.y);
const ChannelList &channels = file->header().channels();
for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i)
{
const Channel &channel = i.channel();
// printf("OpenEXR-load: Found channel %s of type %d\n", i.name(), channel.type);
if (channel.type != 1)
{
printf("OpenEXR-load: Can only process HALF input !!\n");
return(NULL);
}
}
RGBAZ *pixels = new RGBAZ[height * width];
FrameBuffer frameBuffer;
frameBuffer.insert ("R",
Slice (HALF,
(char *) &pixels[0].r,
sizeof (pixels[0]) * 1,
sizeof (pixels[0]) * width));
frameBuffer.insert ("G",
Slice (HALF,
(char *) &pixels[0].g,
sizeof (pixels[0]) * 1,
sizeof (pixels[0]) * width));
frameBuffer.insert ("B",
Slice (HALF,
(char *) &pixels[0].b,
sizeof (pixels[0]) * 1,
sizeof (pixels[0]) * width));
frameBuffer.insert ("A",
Slice (HALF,
(char *) &pixels[0].a,
sizeof (pixels[0]) * 1,
sizeof (pixels[0]) * width));
// FIXME ? Would be able to read Z data or other channels here !
// printf("OpenEXR-load: Reading pixel data\n");
file->setFrameBuffer (frameBuffer);
file->readPixels (dw.min.y, dw.max.y);
// printf("OpenEXR-load: Converting to Blender float ibuf\n");
int bytesperpixel = 4; // since OpenEXR fills in unknown channels
ibuf = IMB_allocImBuf(width, height, 8 * bytesperpixel, 0, 0);
if (ibuf)
{
ibuf->ftype = OPENEXR;
imb_addrectImBuf(ibuf);
imb_addrectfloatImBuf(ibuf);
if (!(flags & IB_test))
{
unsigned char *to = (unsigned char *) ibuf->rect;
float *tof = ibuf->rect_float;
RGBAZ *from = pixels;
RGBAZ prescale;
for (int i = ibuf->x * ibuf->y; i > 0; i--)
{
to[0] = (unsigned char)(from->r > 1.0 ? 1.0 : (float)from->r) * 255;
to[1] = (unsigned char)(from->g > 1.0 ? 1.0 : (float)from->g) * 255;
to[2] = (unsigned char)(from->b > 1.0 ? 1.0 : (float)from->b) * 255;
to[3] = (unsigned char)(from->a > 1.0 ? 1.0 : (float)from->a) * 255;
to += 4;
tof[0] = from->r;
tof[1] = from->g;
tof[2] = from->b;
tof[3] = from->a;
from++;
}
}
IMB_flipy(ibuf);
}
else
printf("Couldn't allocate memory for OpenEXR image\n");
// printf("OpenEXR-load: Done\n");
return(ibuf);
}
catch (const std::exception &exc)
{
std::cerr << exc.what() << std::endl;
if (ibuf) IMB_freeImBuf(ibuf);
return (0);
}
}
} // export "C"

View File

@@ -0,0 +1,63 @@
/**
* $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Austin Benesh.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifndef _OPENEXR_API_H
#define _OPENEXR_API_H
#ifdef __cplusplus
extern "C" {
#endif
#define OPENEXR_FLOATRGB 0x1
#define OPENEXR_ZBUF 0x2
#include <stdio.h>
/**
* Test presence of OpenEXR file.
* @param mem pointer to loaded OpenEXR bitstream
*/
int imb_is_a_openexr(unsigned char *mem);
short imb_save_openexr_half(struct ImBuf *ibuf, char *name, int flags);
short imb_save_openexr_float(struct ImBuf *ibuf, char *name, int flags);
struct ImBuf *imb_load_openexr(unsigned char *mem, int size, int flags);
#ifdef __cplusplus
}
#endif
#endif /* __OPENEXR_API_H */

View File

@@ -29,13 +29,12 @@
* ***** END GPL LICENSE BLOCK *****
*/
/*
-------------------------------------------------------------------------------------------------
/* ----------------------------------------------------------------------
Radiance High Dynamic Range image file IO
For description and code for reading/writing of radiance hdr files by Greg Ward, refer to:
For description and code for reading/writing of radiance hdr files
by Greg Ward, refer to:
http://radsite.lbl.gov/radiance/refer/Notes/picture_format.html
-------------------------------------------------------------------------------------------------
----------------------------------------------------------------------
*/
#ifdef WIN32
@@ -68,9 +67,7 @@ typedef float fCOLOR[3];
#define copy_rgbe(c1, c2) (c2[RED]=c1[RED], c2[GRN]=c1[GRN], c2[BLU]=c1[BLU], c2[EXP]=c1[EXP])
#define copy_fcol(f1, f2) (f2[RED]=f1[RED], f2[GRN]=f1[GRN], f2[BLU]=f1[BLU])
/*-------------------------------------------------------------------------------------------------*/
/* read routines */
static unsigned char* oldreadcolrs(RGBE *scan, unsigned char *mem, int xmax)
{
int i, rshift = 0, len = xmax;
@@ -127,7 +124,6 @@ static unsigned char* freadcolrs(RGBE *scan, unsigned char* mem, int xmax)
return mem;
}
/*-------------------------------------------------------------------------------------------------*/
/* helper functions */
/* rgbe -> float color */
@@ -161,7 +157,6 @@ static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe)
}
}
/*-------------------------------------------------------------------------------------------------*/
/* ImBuf read */
int imb_is_a_hdr(void *buf)
@@ -174,16 +169,17 @@ int imb_is_a_hdr(void *buf)
struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags)
{
int found=0;
char oriY[80], oriX[80];
int width=0, height=0;
RGBE* sline;
int x, y;
char* ptr;
fCOLOR fcol;
int ir, ig, ib;
unsigned char* rect;
struct ImBuf* ibuf;
RGBE* sline;
fCOLOR fcol;
float* rect_float;
int found=0;
int width=0, height=0;
int x, y;
int ir, ig, ib;
unsigned char* ptr;
unsigned char* rect;
char oriY[80], oriX[80];
if (imb_is_a_hdr((void*)mem))
{
@@ -198,11 +194,11 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags)
sscanf((char*)&mem[x+1], "%s %d %s %d", (char*)&oriY, &height, (char*)&oriX, &width);
/* find end of this line, data right behind it */
ptr = strchr((char*)&mem[x+1], '\n');
ptr = (unsigned char *)strchr((char*)&mem[x+1], '\n');
ptr++;
if (flags & IB_test) ibuf = IMB_allocImBuf(width, height, 24, 0, 0);
else ibuf = IMB_allocImBuf(width, height, 24, 1, 0);
else ibuf = IMB_allocImBuf(width, height, 24, IB_rect|IB_rectfloat, 0);
if (ibuf==NULL) return NULL;
ibuf->ftype = RADHDR;
@@ -213,6 +209,8 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags)
/* read in and decode the actual data */
sline = (RGBE*)MEM_mallocN(sizeof(RGBE)*width, "radhdr_read_tmpscan");
rect = (unsigned char*)ibuf->rect;
rect_float = (float *)ibuf->rect_float;
for (y=0;y<height;y++) {
ptr = freadcolrs(sline, ptr, width);
if (ptr==NULL) {
@@ -223,10 +221,13 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags)
for (x=0;x<width;x++) {
/* convert to ldr */
RGBE2FLOAT(sline[x], fcol);
/*--------------------------------------------------------------------------------------*/
/* THIS PART NEEDS TO BE ADAPTED TO WRITE TO IMBUF FLOATBUFFER ONCE THAT IS IMPLEMENTED
* temporarily now loads as regular image using simple tone mapping
* (of course this should NOT be done when loading to floatbuffer!) */
*rect_float++ = fcol[RED];
*rect_float++ = fcol[GRN];
*rect_float++ = fcol[BLU];
*rect_float++ = 255;
/* Also old oldstyle for the rest of blender which is not using floats yet */
/* very weird mapping! (ton) */
fcol[RED] = 1.f-exp(fcol[RED]*-1.414213562f);
fcol[GRN] = 1.f-exp(fcol[GRN]*-1.414213562f);
fcol[BLU] = 1.f-exp(fcol[BLU]*-1.414213562f);
@@ -237,7 +238,6 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags)
*rect++ = (unsigned char)((ig<0) ? 0 : ((ig>255) ? 255 : ig));
*rect++ = (unsigned char)((ib<0) ? 0 : ((ib>255) ? 255 : ib));
*rect++ = 255;
/*--------------------------------------------------------------------------------------*/
}
}
MEM_freeN(sline);
@@ -251,36 +251,39 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags)
return NULL;
}
/*-------------------------------------------------------------------------------------------------*/
/* ImBuf write */
static int fwritecolrs(FILE* file, int width, RGBE* rgbe_scan, unsigned char* ibufscan, float* fpscan)
static int fwritecolrs(FILE* file, int width, unsigned char* ibufscan, float* fpscan)
{
int i, j, beg, c2, cnt=0;
int x, i, j, beg, c2, cnt=0;
fCOLOR fcol;
RGBE rgbe;
RGBE rgbe, *rgbe_scan;
if ((ibufscan==NULL) && (fpscan==NULL)) return 0;
rgbe_scan = (RGBE*)MEM_mallocN(sizeof(RGBE)*width, "radhdr_write_tmpscan");
/* convert scanline */
for (i=0, j=0;i<width;i++, j+=4) {
if (ibufscan) {
fcol[RED] = (float)ibufscan[j] / 255.f;
fcol[GRN] = (float)ibufscan[j+1] / 255.f;
fcol[BLU] = (float)ibufscan[j+2] /255.f;
}
else {
fcol[RED] = fpscan[j];
fcol[GRN] = fpscan[j+1];
fcol[BLU] = fpscan[j+2];
}
FLOAT2RGBE(fcol, rgbe);
copy_rgbe(rgbe, rgbe_scan[i]);
j= 0;
for (i=0;i<width;i++) {
if (fpscan) {
fcol[RED] = fpscan[j];
fcol[GRN] = fpscan[j+1];
fcol[BLU] = fpscan[j+2];
} else {
fcol[RED] = (float)ibufscan[j] / 255.f;
fcol[GRN] = (float)ibufscan[j+1] / 255.f;
fcol[BLU] = (float)ibufscan[j+2] /255.f;
}
FLOAT2RGBE(fcol, rgbe);
copy_rgbe(rgbe, rgbe_scan[i]);
j+=4;
}
if ((width < MINELEN) | (width > MAXELEN)) /* OOBs, write out flat */
return (fwrite((char *)rgbe_scan, sizeof(RGBE), width, file) - width);
if ((width < MINELEN) | (width > MAXELEN)) { /* OOBs, write out flat */
x=fwrite((char *)rgbe_scan, sizeof(RGBE), width, file) - width;
MEM_freeN(rgbe_scan);
return x;
}
/* put magic header */
putc(2, file);
putc(2, file);
@@ -315,6 +318,7 @@ static int fwritecolrs(FILE* file, int width, RGBE* rgbe_scan, unsigned char* ib
else cnt = 0;
}
}
MEM_freeN(rgbe_scan);
return(ferror(file) ? -1 : 0);
}
@@ -336,57 +340,21 @@ static void writeHeader(FILE *file, int width, int height)
short imb_savehdr(struct ImBuf *ibuf, char *name, int flags)
{
int y, width=ibuf->x, height=ibuf->y;
RGBE* sline;
FILE* file = fopen(name, "wb");
if (file==NULL) return 0;
writeHeader(file, width, height);
sline = (RGBE*)MEM_mallocN(sizeof(RGBE)*width, "radhdr_write_tmpscan");
for (y=height-1;y>=0;y--) {
if (fwritecolrs(file, width, sline, (unsigned char*)&ibuf->rect[y*width], NULL) < 0)
{ // error
if (fwritecolrs(file, width,(unsigned char *)&ibuf->rect[y*width*4], &ibuf->rect_float[y*width*4]) < 0) {
fclose(file);
MEM_freeN(sline);
printf("HDR write error\n");
return 0;
}
}
fclose(file);
MEM_freeN(sline);
return 1;
}
/* Temporary routine to save directly from render floatbuffer.
Called by schrijfplaatje() in toets.c */
short imb_savehdr_fromfloat(float *fbuf, char *name, int width, int height)
{
int y;
RGBE* sline;
FILE* file = fopen(name, "wb");
if (file==NULL) return 0;
writeHeader(file, width, height);
sline = (RGBE*)MEM_mallocN(sizeof(RGBE)*width, "radhdr_write_tmpscan");
for (y=height-1;y>=0;y--) {
if (fwritecolrs(file, width, sline, NULL, &fbuf[y*width*4]) < 0)
{ // error
fclose(file);
MEM_freeN(sline);
printf("HDR write error\n");
return 0;
}
}
fclose(file);
MEM_freeN(sline);
return 1;
}
/*-------------------------------------------------------------------------------------------------*/

View File

@@ -54,6 +54,10 @@
#include "IMB_radiance_hdr.h"
#include "BKE_global.h"
#ifdef WITH_OPENEXR
#include "openexr/openexr_api.h"
#endif
#ifdef WITH_QUICKTIME
#if defined(_WIN32) || defined (__APPLE__)
#include "quicktime_import.h"
@@ -138,6 +142,9 @@ ImBuf *IMB_ibImageFromMemory(int *mem, int size, int flags) {
ibuf = imb_loadhdr((uchar*)mem, size, flags);
if (ibuf) return (ibuf);
ibuf = imb_load_openexr((uchar *)mem, size, flags);
if (ibuf) return (ibuf);
#ifdef WITH_QUICKTIME
#if defined(_WIN32) || defined (__APPLE__)
if(G.have_quicktime) {

View File

@@ -41,33 +41,17 @@
#include "IMB_allocimbuf.h"
void IMB_rectcpy(unsigned int *drect, unsigned int *srect, int x, int dummy)
void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx,
int desty, int srcx, int srcy, int width, int height)
{
memcpy(drect,srect, x * sizeof(int));
}
unsigned int *drect, *srect;
float *drectf = NULL;
float *srectf = NULL;
int tmp, do_float = 0;
void IMB_rectfill(unsigned int *drect, unsigned int *srect, int x, int value)
{
for (;x > 0; x--) *drect++ = value;
}
void IMB_rectop(struct ImBuf *dbuf,
struct ImBuf *sbuf,
int destx,
int desty,
int srcx,
int srcy,
int width,
int height,
void (*operation)(unsigned int *, unsigned int*, int, int),
int value)
{
unsigned int *drect,*srect;
int tmp;
if (dbuf == 0) return;
if (operation == 0) return;
if (dbuf == NULL) return;
if (sbuf->rect_float) do_float = 1;
if (destx < 0){
srcx -= destx ;
@@ -96,6 +80,7 @@ void IMB_rectop(struct ImBuf *dbuf,
if (height > tmp) height = tmp;
drect = dbuf->rect + desty * dbuf->x + destx;
if (do_float) drectf = dbuf->rect_float + desty * dbuf->x + destx;
destx = dbuf->x;
if (sbuf){
@@ -110,25 +95,53 @@ void IMB_rectop(struct ImBuf *dbuf,
srect = sbuf->rect;
srect += srcy * sbuf->x;
srect += srcx;
if (do_float) {
srectf = sbuf->rect_float;
srectf += srcy * sbuf->x;
srectf += srcx;
}
srcx = sbuf->x;
} else{
if (width <= 0) return;
if (height <= 0) return;
srect = drect;
srectf = drectf;
srcx = destx;
}
for (;height > 0; height--){
operation(drect,srect,width, value);
drect += destx;
srect += srcx;
memcpy(drect,srect, width * sizeof(int));
if (do_float) memcpy(drectf,srectf, width * sizeof(float) * 4);
}
}
void IMB_rectoptot(struct ImBuf *dbuf, struct ImBuf *sbuf,
void (*operation)(unsigned int *, unsigned int*, int, int), int value)
void IMB_rectfill(struct ImBuf *drect, float col[4])
{
IMB_rectop(dbuf,sbuf,0,0,0,0,32767,32767,operation, value);
int num;
unsigned int *rrect = drect->rect;
unsigned char *spot;
num = drect->x * drect->y;
for (;num > 0; num--) {
spot = (unsigned char *)rrect;
spot[0] = (int)(col[0]*255);
spot[1] = (int)(col[1]*255);
spot[2] = (int)(col[2]*255);
spot[3] = (int)(col[3]*255);
*rrect++;
}
if(drect->rect_float) {
float *rrectf = drect->rect_float;
num = drect->x * drect->y;
for (;num > 0; num--) {
*rrectf++ = col[0];
*rrectf++ = col[1];
*rrectf++ = col[2];
*rrectf++ = col[3];
}
}
}

View File

@@ -43,26 +43,46 @@
void IMB_flipy(struct ImBuf * ibuf)
{
short x,y,backx;
unsigned int *top,*bottom,temp;
short x, y;
unsigned int *top, *bottom, do_float=0, *line;
float *topf=NULL, *bottomf=NULL, *linef=NULL;
if (ibuf == 0) return;
if (ibuf->rect == 0) return;
if (ibuf == NULL) return;
if (ibuf->rect == NULL) return;
if (ibuf->rect_float) do_float =1;
x = ibuf->x;
y = ibuf->y;
backx = x<<1;
top = ibuf->rect;
bottom = top + ((y-1) * x);
line= MEM_mallocN(x*sizeof(int), "linebuf");
if (do_float) {
topf= ibuf->rect_float;
bottomf = topf + 4*((y-1) * x);
linef= MEM_mallocN(4*x*sizeof(float), "linebuff");
}
y >>= 1;
for(;y>0;y--){
for(x = ibuf->x; x > 0; x--){
temp = *top;
*(top++) = *bottom;
*(bottom++) = temp;
for(;y>0;y--) {
memcpy(line, top, x*sizeof(int));
memcpy(top, bottom, x*sizeof(int));
memcpy(bottom, line, x*sizeof(int));
bottom -= x;
top+= x;
if(do_float) {
memcpy(linef, topf, 4*x*sizeof(float));
memcpy(topf, bottomf, 4*x*sizeof(float));
memcpy(bottomf, linef, 4*x*sizeof(float));
bottomf -= 4*x;
topf+= 4*x;
}
bottom -= backx;
}
MEM_freeN(line);
if(linef) MEM_freeN(linef);
}

View File

@@ -52,20 +52,27 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1)
struct ImBuf *ibuf2;
uchar *p1,*_p1,*dest;
short a,r,g,b,x,y;
float af,rf,gf,bf, *p1f, *_p1f, *destf;
int do_float = 0;
if (ibuf1==0) return (0);
if (ibuf1->rect == 0) return (0);
if (ibuf1==NULL) return (0);
if (ibuf1->rect==NULL) return (0);
if (ibuf1->rect_float) do_float = 1;
if (ibuf1->x <= 1) return(IMB_dupImBuf(ibuf1));
ibuf2 = IMB_allocImBuf((ibuf1->x)/2 , ibuf1->y , ibuf1->depth,1,0);
if (ibuf2==0) return (0);
ibuf2 = IMB_allocImBuf((ibuf1->x)/2, ibuf1->y, ibuf1->depth, ibuf1->flags, 0);
if (ibuf2==NULL) return (0);
_p1 = (uchar *) ibuf1->rect;
dest=(uchar *) ibuf2->rect;
_p1f = ibuf1->rect_float;
destf= ibuf2->rect_float;
for(y=ibuf2->y;y>0;y--){
p1 = _p1;
p1f = _p1f;
for(x = ibuf2->x ; x>0 ; x--){
a = *(p1++) ;
b = *(p1++) ;
@@ -79,8 +86,23 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1)
*(dest++) = b >> 1;
*(dest++) = g >> 1;
*(dest++) = r >> 1;
if (do_float) {
af = *(p1f++);
bf = *(p1f++);
gf = *(p1f++);
rf = *(p1f++);
af += *(p1f++);
bf += *(p1f++);
gf += *(p1f++);
rf += *(p1f++);
*(destf++) = 0.5f*af;
*(destf++) = 0.5f*bf;
*(destf++) = 0.5f*gf;
*(destf++) = 0.5f*rf;
}
}
_p1 += (ibuf1->x << 2);
if (do_float) _p1f += (ibuf1->x << 2);
}
return (ibuf2);
}
@@ -89,21 +111,30 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1)
struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
int *p1,*dest, i, col;
int *p1,*dest, i, col, do_float=0;
float *p1f, *destf, colf;
if (ibuf1==0) return (0);
if (ibuf1->rect == 0) return (0);
if (ibuf1==NULL) return (0);
if (ibuf1->rect==NULL) return (0);
if (ibuf1->rect_float) do_float = 1;
ibuf2 = IMB_allocImBuf(2 * ibuf1->x , ibuf1->y , ibuf1->depth,1,0);
if (ibuf2==0) return (0);
ibuf2 = IMB_allocImBuf(2 * ibuf1->x , ibuf1->y , ibuf1->depth, ibuf1->flags, 0);
if (ibuf2==NULL) return (0);
p1 = (int *) ibuf1->rect;
dest=(int *) ibuf2->rect;
p1f = ibuf1->rect_float;
destf = ibuf2->rect_float;
for(i = ibuf1->y * ibuf1->x ; i>0 ; i--) {
col = *p1++;
*dest++ = col;
*dest++ = col;
if (do_float) {
colf = *p1f++;
*destf++ = col;
*destf++ = col;
}
}
return (ibuf2);
@@ -113,8 +144,8 @@ struct ImBuf *IMB_double_x(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
if (ibuf1==0) return (0);
if (ibuf1->rect == 0) return (0);
if (ibuf1==NULL) return (0);
if (ibuf1->rect==NULL) return (0);
ibuf2 = IMB_double_fast_x(ibuf1);
@@ -128,20 +159,30 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1)
struct ImBuf *ibuf2;
uchar *p1,*p2,*_p1,*dest;
short a,r,g,b,x,y;
int do_float = 0;
float af,rf,gf,bf,*p1f,*p2f,*_p1f,*destf;
if (ibuf1==0) return (0);
if (ibuf1->rect == 0) return (0);
p1f = NULL; p2f = NULL;
if (ibuf1==NULL) return (0);
if (ibuf1->rect==NULL) return (0);
if (ibuf1->rect_float) do_float = 1;
if (ibuf1->y <= 1) return(IMB_dupImBuf(ibuf1));
ibuf2 = IMB_allocImBuf(ibuf1->x , (ibuf1->y) / 2 , ibuf1->depth,1,0);
if (ibuf2==0) return (0);
ibuf2 = IMB_allocImBuf(ibuf1->x , (ibuf1->y) / 2 , ibuf1->depth, ibuf1->flags, 0);
if (ibuf2==NULL) return (0);
_p1 = (uchar *) ibuf1->rect;
dest=(uchar *) ibuf2->rect;
_p1f = ibuf1->rect_float;
destf= ibuf2->rect_float;
for(y=ibuf2->y ; y>0 ; y--){
p1 = _p1;
p2 = _p1 + (ibuf1->x << 2);
if (do_float) {
p1f = _p1f;
p2f = _p1f + (ibuf1->x << 2);
}
for(x = ibuf2->x ; x>0 ; x--){
a = *(p1++) ;
b = *(p1++) ;
@@ -155,8 +196,23 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1)
*(dest++) = b >> 1;
*(dest++) = g >> 1;
*(dest++) = r >> 1;
if (do_float) {
af = *(p1f++) ;
bf = *(p1f++) ;
gf = *(p1f++) ;
rf = *(p1f++);
af += *(p2f++) ;
bf += *(p2f++) ;
gf += *(p2f++) ;
rf += *(p2f++);
*(destf++) = 0.5f*af;
*(destf++) = 0.5f*bf;
*(destf++) = 0.5f*gf;
*(destf++) = 0.5f*rf;
}
}
_p1 += (ibuf1->x << 3);
if (do_float) _p1f += (ibuf1->x << 3);
}
return (ibuf2);
}
@@ -166,21 +222,31 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
int *p1, *dest1, *dest2;
float *p1f, *dest1f, *dest2f;
short x,y;
int do_float =0;
if (ibuf1==0) return (0);
if (ibuf1->rect == 0) return (0);
if (ibuf1==NULL) return (0);
if (ibuf1->rect==NULL) return (0);
if (ibuf1->rect_float) do_float =1;
ibuf2 = IMB_allocImBuf(ibuf1->x , 2 * ibuf1->y , ibuf1->depth,1,0);
if (ibuf2==0) return (0);
ibuf2 = IMB_allocImBuf(ibuf1->x , 2 * ibuf1->y , ibuf1->depth, ibuf1->flags, 0);
if (ibuf2==NULL) return (0);
p1 = (int *) ibuf1->rect;
dest1=(int *) ibuf2->rect;
p1f = ibuf1->rect_float;
dest1f= ibuf2->rect_float;
for(y = ibuf1->y ; y>0 ; y--){
dest2 = dest1 + ibuf2->x;
for(x = ibuf2->x ; x>0 ; x--) *dest1++ = *dest2++ = *p1++;
dest1 = dest2;
if (do_float) {
dest2f = dest1f + ibuf2->x;
for(x = ibuf2->x ; x>0 ; x--) *dest1f++ = *dest2f++ = *p1f++;
dest1f = dest2f;
}
}
return (ibuf2);
@@ -190,8 +256,8 @@ struct ImBuf *IMB_double_y(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
if (ibuf1==0) return (0);
if (ibuf1->rect == 0) return (0);
if (ibuf1==NULL) return (0);
if (ibuf1->rect==NULL) return (0);
ibuf2 = IMB_double_fast_y(ibuf1);
@@ -203,23 +269,29 @@ struct ImBuf *IMB_double_y(struct ImBuf *ibuf1)
struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
uchar *p1,*p2,*dest;
uchar *p1, *p2, *dest;
float *p1f, *destf, *p2f = NULL;
int x,y;
int do_float =0;
if (ibuf1 == 0) return (0);
if (ibuf1->rect == 0) return (0);
if (ibuf1==NULL) return (0);
if (ibuf1->rect==NULL) return (0);
if (ibuf1->rect_float) do_float = 1;
if (ibuf1->x <= 1) return(IMB_half_y(ibuf1));
if (ibuf1->y <= 1) return(IMB_half_x(ibuf1));
ibuf2=IMB_allocImBuf((ibuf1->x)/2,(ibuf1->y)/2,ibuf1->depth,1,0);
if (ibuf2==0) return (0);
ibuf2=IMB_allocImBuf((ibuf1->x)/2, (ibuf1->y)/2, ibuf1->depth, ibuf1->flags, 0);
if (ibuf2==NULL) return (0);
p1f = ibuf1->rect_float;
destf=ibuf2->rect_float;
p1 = (uchar *) ibuf1->rect;
dest=(uchar *) ibuf2->rect;
for(y=ibuf2->y;y>0;y--){
p2 = p1 + (ibuf1->x << 2);
if (do_float) p2f = p1f + (ibuf1->x << 2);
for(x=ibuf2->x;x>0;x--){
dest[0] = (p1[0] + p2[0] + p1[4] + p2[4]) >> 2;
dest[1] = (p1[1] + p2[1] + p1[5] + p2[5]) >> 2;
@@ -228,10 +300,21 @@ struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1)
p1 += 8;
p2 += 8;
dest += 4;
if (do_float){
destf[0] = 0.25f*(p1f[0] + p2f[0] + p1f[4] + p2f[4]);
destf[1] = 0.25f*(p1f[1] + p2f[1] + p1f[5] + p2f[5]);
destf[2] = 0.25f*(p1f[2] + p2f[2] + p1f[6] + p2f[6]);
destf[3] = 0.25f*(p1f[3] + p2f[3] + p1f[7] + p2f[7]);
p1f += 8;
p2f += 8;
destf += 4;
}
}
p1=p2;
if (do_float) p1f=p2f;
if(ibuf1->x & 1) {
p1+=4;
if (do_float) p1f+=4;
}
}
return (ibuf2);
@@ -243,34 +326,59 @@ struct ImBuf *IMB_onethird(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
uchar *p1,*p2,*p3,*dest;
float *p1f, *p2f, *p3f, *destf;
int do_float=0;
short a,r,g,b,x,y,i;
float af,rf,gf,bf;
if (ibuf1 == 0) return (0);
if (ibuf1->rect == 0) return (0);
p2f = NULL; p3f = NULL;
if (ibuf1==NULL) return (0);
if (ibuf1->rect==NULL) return (0);
if (ibuf1->rect_float) do_float = 1;
ibuf2=IMB_allocImBuf((ibuf1->x)/3,(ibuf1->y)/3,ibuf1->depth,1,0);
if (ibuf2==0) return (0);
ibuf2=IMB_allocImBuf((ibuf1->x)/3, (ibuf1->y)/3, ibuf1->depth, ibuf1->flags, 0);
if (ibuf2==NULL) return (0);
p1f = ibuf1->rect_float;
destf = ibuf2->rect_float;
p1 = (uchar *) ibuf1->rect;
dest=(uchar *) ibuf2->rect;
for(y=ibuf2->y;y>0;y--){
p2 = p1 + (ibuf1->x << 2);
p3 = p2 + (ibuf1->x << 2);
if (do_float) {
p2f = p1f + (ibuf1->x <<2);
p3f = p2f + (ibuf1->x <<2);
}
for(x=ibuf2->x;x>0;x--){
a=r=g=b=0;
af=rf=gf=bf=0;
for (i=3;i>0;i--){
a += *(p1++) + *(p2++) + *(p3++);
b += *(p1++) + *(p2++) + *(p3++);
g += *(p1++) + *(p2++) + *(p3++);
r += *(p1++) + *(p2++) + *(p3++);
if (do_float) {
af += *(p1f++) + *(p2f++) + *(p3f++);
bf += *(p1f++) + *(p2f++) + *(p3f++);
gf += *(p1f++) + *(p2f++) + *(p3f++);
rf += *(p1f++) + *(p2f++) + *(p3f++);
}
}
*(dest++) = a/9;
*(dest++) = b/9;
*(dest++) = g/9;
*(dest++) = r/9;
if (do_float) {
*(destf++) = af/9.0f;
*(destf++) = bf/9.0f;
*(destf++) = gf/9.0f;
*(destf++) = rf/9.0f;
}
}
p1=p3;
if (do_float) p1f = p3f;
}
return (ibuf2);
}
@@ -280,33 +388,55 @@ struct ImBuf *IMB_halflace(struct ImBuf *ibuf1)
{
struct ImBuf *ibuf2;
uchar *p1,*p2,*dest;
float *p1f,*p2f,*destf;
short a,r,g,b,x,y,i;
float af,rf,gf,bf;
int do_float = 0;
if (ibuf1 == 0) return (0);
if (ibuf1->rect == 0) return (0);
p2f = NULL;
if (ibuf1==NULL) return (0);
if (ibuf1->rect==NULL) return (0);
if (ibuf1->rect_float) do_float = 1;
ibuf2=IMB_allocImBuf((ibuf1->x)/4,(ibuf1->y)/2,ibuf1->depth,1,0);
if (ibuf2==0) return (0);
ibuf2=IMB_allocImBuf((ibuf1->x)/4, (ibuf1->y)/2, ibuf1->depth, ibuf1->flags, 0);
if (ibuf2==NULL) return (0);
p1f = ibuf1->rect_float;
destf= ibuf2->rect_float;
p1 = (uchar *) ibuf1->rect;
dest=(uchar *) ibuf2->rect;
for(y= ibuf2->y / 2 ; y>0;y--){
p2 = p1 + (ibuf1->x << 3);
if (do_float) p2f = p1f + (ibuf1->x << 3);
for(x = 2 * ibuf2->x;x>0;x--){
a=r=g=b=0;
af=rf=gf=bf=0;
for (i=4;i>0;i--){
a += *(p1++) + *(p2++);
b += *(p1++) + *(p2++);
g += *(p1++) + *(p2++);
r += *(p1++) + *(p2++);
if (do_float) {
af += *(p1f++) + *(p2f++);
bf += *(p1f++) + *(p2f++);
gf += *(p1f++) + *(p2f++);
rf += *(p1f++) + *(p2f++);
}
}
*(dest++) = a >> 3;
*(dest++) = b >> 3;
*(dest++) = g >> 3;
*(dest++) = r >> 3;
if (do_float) {
*(destf++) = 0.125f*af;
*(destf++) = 0.125f*bf;
*(destf++) = 0.125f*gf;
*(destf++) = 0.125f*rf;
}
}
p1 = p2;
if (do_float) p1f = p2f;
}
return (ibuf2);
}
@@ -315,14 +445,23 @@ struct ImBuf *IMB_halflace(struct ImBuf *ibuf1)
static struct ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
{
uchar *rect,*_newrect,*newrect;
float sample, add, val, nval;
int x, y, i;
float *rectf,*_newrectf,*newrectf;
float sample, add, val, nval, valf, nvalf;
int x, y, i, do_float=0;
if (ibuf == 0) return(0);
if (ibuf->rect == 0) return(ibuf);
rectf = NULL; _newrectf= NULL; newrectf = NULL;
nval = 0; nvalf = 0;
if (ibuf==NULL) return(0);
if (ibuf->rect==NULL) return(ibuf);
if (ibuf->rect_float) {
do_float = 1;
_newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaledownxf");
if (_newrectf==NULL) return(ibuf);
}
_newrect = (uchar *) malloc(newx * ibuf->y * sizeof(int));
if (_newrect == 0) return(ibuf);
_newrect = MEM_mallocN(newx * ibuf->y * sizeof(int), "scaledownx");
if (_newrect==NULL) return(ibuf);
add = (ibuf->x - 0.001) / newx;
@@ -331,22 +470,39 @@ static struct ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
rect = (uchar *) ibuf->rect;
rect += i;
newrect = _newrect + i;
if (do_float) {
rectf = ibuf->rect_float;
rectf += i;
newrectf = _newrectf + i;
}
for (y = ibuf->y; y>0 ; y--){
val = sample = 0.0;
val = sample = valf = 0.0;
for (x = newx ; x>0 ; x--){
nval = - val * sample;
if (do_float) nvalf = - valf * sample;
sample += add;
while (sample >= 1.0){
sample -= 1.0;
nval += *rect;
rect += 4;
if (do_float) {
nvalf += *rectf;
rectf += 4;
}
}
val = *rect;
rect += 4;
nval += sample * val;
if (do_float) {
valf = *rectf;
rectf += 4;
nvalf += sample * valf;
*newrectf = (nvalf/add) + 0.5;
newrectf += 4;
}
sample -= 1.0;
*newrect = (nval/add) + 0.5;
newrect += 4;
@@ -357,6 +513,13 @@ static struct ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
imb_freerectImBuf(ibuf);
ibuf->mall |= IB_rect;
ibuf->rect = (unsigned int *) _newrect;
if (do_float) {
imb_freerectfloatImBuf(ibuf);
ibuf->mall |= IB_rectfloat;
ibuf->rect_float = _newrectf;
}
ibuf->x = newx;
return(ibuf);
}
@@ -364,15 +527,25 @@ static struct ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
{
uchar *rect,*_newrect,*newrect;
float sample,add,val,nval;
int x,y,i,skipx;
uchar *rect, *_newrect, *newrect;
float *rectf, *_newrectf, *newrectf;
float sample, add, val, nval, valf, nvalf;
int x, y, i, skipx, do_float = 0;
if (ibuf == 0) return(0);
if (ibuf->rect == 0) return(ibuf);
rectf= NULL; _newrectf = NULL; newrectf = NULL;
nval = 0; nvalf = 0;
_newrect = (uchar *) malloc(newy * ibuf->x * sizeof(int));
if (_newrect == 0) return(ibuf);
if (ibuf==NULL) return(0);
if (ibuf->rect==NULL) return(ibuf);
if (ibuf->rect_float) {
do_float = 1;
_newrectf = MEM_mallocN(newy * ibuf->x * sizeof(float) * 4, "scaldownyf");
if (_newrectf==NULL) return(ibuf);
}
_newrect = MEM_mallocN(newy * ibuf->x * sizeof(int), "scaledowny");
if (_newrect==NULL) return(ibuf);
add = (ibuf->y - 0.001) / newy;
skipx = 4 * ibuf->x;
@@ -382,23 +555,39 @@ static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
for (x = skipx - 4; x>=0 ; x-= 4){
rect = ((uchar *) ibuf->rect) + i + x;
newrect = _newrect + i + x;
if (do_float) {
rectf = ((float *) ibuf->rect_float) + i + x;
newrectf = _newrectf + i + x;
}
val = sample = 0.0;
for (y = newy ; y>0 ; y--){
nval = - val * sample;
if (do_float) nvalf = - val * sample;
sample += add;
while (sample >= 1.0){
sample -= 1.0;
nval += *rect;
rect += skipx;
if (do_float) {
nvalf += *rectf;
rectf += skipx;
}
}
val = *rect;
rect += skipx;
nval += sample * val;
sample -= 1.0;
*newrect = (nval/add) + 0.5;
newrect += skipx;
if (do_float) {
valf = *rectf;
rectf += skipx;
nvalf += sample * valf;
*newrectf = (nvalf/add) + 0.5;
newrectf += skipx;
}
sample -= 1.0;
}
}
}
@@ -406,6 +595,13 @@ static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
imb_freerectImBuf(ibuf);
ibuf->mall |= IB_rect;
ibuf->rect = (unsigned int *) _newrect;
if (do_float) {
imb_freerectfloatImBuf(ibuf);
ibuf->mall |= IB_rectfloat;
ibuf->rect_float = (float *) _newrectf;
}
ibuf->y = newy;
return(ibuf);
}
@@ -414,23 +610,39 @@ static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
{
uchar *rect,*_newrect,*newrect;
float *rectf,*_newrectf,*newrectf;
float sample,add;
float val_a,nval_a,diff_a;
float val_b,nval_b,diff_b;
float val_g,nval_g,diff_g;
float val_r,nval_r,diff_r;
int x,y;
float val_af,nval_af,diff_af;
float val_bf,nval_bf,diff_bf;
float val_gf,nval_gf,diff_gf;
float val_rf,nval_rf,diff_rf;
int x,y, do_float = 0;
if (ibuf == 0) return(0);
if (ibuf->rect == 0) return(ibuf);
val_af = nval_af = diff_af = val_bf = nval_bf = diff_bf = 0;
val_gf = nval_gf = diff_gf = val_rf = nval_rf = diff_rf = 0;
if (ibuf==NULL) return(0);
if (ibuf->rect==NULL) return(ibuf);
_newrect = MEM_mallocN(newx * ibuf->y * sizeof(int), "scaleupx");
if (_newrect==NULL) return(ibuf);
if (ibuf->rect_float) {
do_float = 1;
_newrectf = MEM_mallocN(newx * ibuf->y * sizeof(float) * 4, "scaleupxf");
if (_newrectf==NULL) return(ibuf);
}
_newrect = (uchar *) malloc(newx * ibuf->y * sizeof(int));
if (_newrect == 0) return(ibuf);
add = (ibuf->x - 1.001) / (newx - 1.0);
rect = (uchar *) ibuf->rect;
rectf = (float *) ibuf->rect_float;
newrect = _newrect;
newrectf = _newrectf = NULL;
for (y = ibuf->y; y>0 ; y--){
@@ -456,9 +668,34 @@ static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
val_r += 0.5;
rect += 8;
if (do_float) {
val_af = rectf[0] ;
nval_af = rectf[4];
diff_af = nval_af - val_af;
val_af += 0.5;
val_bf = rectf[1] ;
nval_bf = rectf[5];
diff_bf = nval_bf - val_bf;
val_bf += 0.5;
val_gf = rectf[2] ;
nval_gf = rectf[6];
diff_gf = nval_gf - val_gf;
val_gf += 0.5;
val_rf = rectf[3] ;
nval_rf = rectf[7];
diff_rf = nval_rf - val_rf;
val_rf += 0.5;
rectf += 8;
}
for (x = newx ; x>0 ; x--){
if (sample >= 1.0){
sample -= 1.0;
val_a = nval_a ;
nval_a = rect[0] ;
diff_a = nval_a - val_a ;
@@ -479,12 +716,42 @@ static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
diff_r = nval_r - val_r ;
val_r += 0.5;
rect += 4;
if (do_float) {
val_af = nval_af ;
nval_af = rectf[0] ;
diff_af = nval_af - val_af ;
val_af += 0.5;
val_bf = nval_bf ;
nval_bf = rectf[1] ;
diff_bf = nval_bf - val_bf ;
val_bf += 0.5;
val_gf = nval_gf ;
nval_gf = rectf[2] ;
diff_gf = nval_gf - val_gf ;
val_gf += 0.5;
val_rf = nval_rf ;
nval_rf = rectf[3] ;
diff_rf = nval_rf - val_rf;
val_rf += 0.5;
rectf += 4;
}
}
newrect[0] = val_a + sample * diff_a;
newrect[1] = val_b + sample * diff_b;
newrect[2] = val_g + sample * diff_g;
newrect[3] = val_r + sample * diff_r;
newrect += 4;
if (do_float) {
newrectf[0] = val_af + sample * diff_af;
newrectf[1] = val_bf + sample * diff_bf;
newrectf[2] = val_gf + sample * diff_gf;
newrectf[3] = val_rf + sample * diff_rf;
newrectf += 4;
}
sample += add;
}
}
@@ -492,6 +759,13 @@ static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
imb_freerectImBuf(ibuf);
ibuf->mall |= IB_rect;
ibuf->rect = (unsigned int *) _newrect;
if (do_float) {
imb_freerectfloatImBuf(ibuf);
ibuf->mall |= IB_rectfloat;
ibuf->rect_float = (float *) _newrectf;
}
ibuf->x = newx;
return(ibuf);
}
@@ -500,24 +774,44 @@ static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx)
static struct ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
{
uchar *rect,*_newrect,*newrect;
float sample,add,val,nval,diff;
int x,y,i,skipx;
float *rectf = NULL, *newrectf = NULL, *_newrectf = NULL;
float sample,add,val,nval,diff, valf=0.0f, nvalf=0.0f, difff=0.0f;
int x,y,i,skipx, do_float = 0;
if (ibuf == 0) return(0);
if (ibuf->rect == 0) return(ibuf);
if (ibuf==NULL) return(0);
if (ibuf->rect==NULL) return(ibuf);
_newrect = (uchar *)malloc(newy * ibuf->x * sizeof(int));
if (_newrect == 0) return(ibuf);
_newrect = MEM_mallocN(newy * ibuf->x * sizeof(int), "scaleupy");
if (_newrect==NULL) return(ibuf);
if (ibuf->rect_float) {
do_float = 1;
_newrectf = MEM_mallocN(newy * ibuf->y * sizeof(float) * 4, "scaleupyf");
if (_newrectf==NULL) return(ibuf);
}
add = (ibuf->y - 1.001) / (newy - 1.0);
skipx = 4 * ibuf->x;
/* all four components, rgba/abgr */
for(i=3 ; i>=0 ; i--){
for (x = skipx - 4; x >= 0 ; x -= 4){
rect = (uchar *) ibuf->rect;
rect += i + x;
newrect = _newrect + i + x;
if (do_float) {
rectf = ibuf->rect_float;
rectf += i * x;
newrectf = _newrectf + i + x;
valf = *rectf;
rectf += skipx;
nvalf = *rectf;
rectf += skipx;
difff = nvalf - valf;
valf += 0.5;
}
sample = 0;
val = *rect ;
@@ -535,9 +829,22 @@ static struct ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
rect += skipx;
diff = nval - val;
val += 0.5;
if (do_float) {
valf = nvalf;
nvalf = *rectf;
rectf += skipx;
difff = nvalf - valf;
valf += 0.5;
}
}
*newrect = val + sample * diff;
newrect += skipx;
if (do_float) {
*newrectf = valf + sample * difff;
newrectf += skipx;
}
sample += add;
}
}
@@ -546,20 +853,28 @@ static struct ImBuf *scaleupy(struct ImBuf *ibuf, int newy)
imb_freerectImBuf(ibuf);
ibuf->mall |= IB_rect;
ibuf->rect = (unsigned int *) _newrect;
if(do_float) {
imb_freerectfloatImBuf(ibuf);
ibuf->mall |= IB_rectfloat;
ibuf->rect_float = _newrectf;
}
ibuf->y = newy;
return(ibuf);
}
/* no float buf needed here! */
static void scalefast_Z_ImBuf(ImBuf *ibuf, short newx, short newy)
{
unsigned int *rect,*_newrect,*newrect;
int x,y;
int ofsx,ofsy,stepx,stepy;
unsigned int *rect, *_newrect, *newrect;
int x, y;
int ofsx, ofsy, stepx, stepy;
if (ibuf->zbuf) {
_newrect = malloc(newx * newy * sizeof(int));
if (_newrect == 0) return;
_newrect = MEM_mallocN(newx * newy * sizeof(int), "z rect");
if (_newrect==NULL) return;
stepx = (65536.0 * (ibuf->x - 1.0) / (newx - 1.0)) + 0.5;
stepy = (65536.0 * (ibuf->y - 1.0) / (newy - 1.0)) + 0.5;
ofsy = 32768;
@@ -585,8 +900,8 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, short newx, short newy)
struct ImBuf *IMB_scaleImBuf(struct ImBuf * ibuf, short newx, short newy)
{
if (ibuf == 0) return (0);
if (ibuf->rect == 0) return (ibuf);
if (ibuf==NULL) return (0);
if (ibuf->rect==NULL) return (ibuf);
// scaleup / scaledown functions below change ibuf->x and ibuf->y
// so we first scale the Z-buffer (if any)
@@ -604,18 +919,28 @@ struct ImBuf *IMB_scaleImBuf(struct ImBuf * ibuf, short newx, short newy)
struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy)
{
unsigned int *rect,*_newrect,*newrect;
int x,y;
float *rectf,*_newrectf,*newrectf;
int x,y, do_float=0;
int ofsx,ofsy,stepx,stepy;
if (ibuf == 0) return(0);
if (ibuf->rect == 0) return(ibuf);
rectf = NULL; _newrectf = NULL; newrectf = NULL;
if (ibuf==NULL) return(0);
if (ibuf->rect==NULL) return(ibuf);
if (ibuf->rect_float) do_float = 1;
if (newx == ibuf->x && newy == ibuf->y) return(ibuf);
_newrect = malloc(newx * newy * sizeof(int));
if (_newrect == 0) return(ibuf);
_newrect = MEM_mallocN(newx * newy * sizeof(int), "scalefastimbuf");
if (_newrect==NULL) return(ibuf);
newrect = _newrect;
if (do_float) {
_newrectf = MEM_mallocN(newx * newy * sizeof(float) * 4, "scalefastimbuf f");
if (_newrectf==NULL) return(ibuf);
newrectf = _newrectf;
}
stepx = (65536.0 * (ibuf->x - 1.0) / (newx - 1.0)) + 0.5;
stepy = (65536.0 * (ibuf->y - 1.0) / (newy - 1.0)) + 0.5;
ofsy = 32768;
@@ -623,10 +948,16 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy)
for (y = newy; y > 0 ; y--){
rect = ibuf->rect;
rect += (ofsy >> 16) * ibuf->x;
if (do_float) {
rectf = ibuf->rect_float;
rectf += (ofsy >> 16) * ibuf->x;
}
ofsy += stepy;
ofsx = 32768;
for (x = newx ; x>0 ; x--){
*newrect++ = rect[ofsx >> 16];
if (do_float) *newrectf++ = rectf[ofsx >> 16];
ofsx += stepx;
}
}
@@ -635,6 +966,12 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy)
ibuf->mall |= IB_rect;
ibuf->rect = _newrect;
if (do_float) {
imb_freerectfloatImBuf(ibuf);
ibuf->mall |= IB_rectfloat;
ibuf->rect_float = _newrectf;
}
scalefast_Z_ImBuf(ibuf, newx, newy);
ibuf->x = newx;
@@ -646,33 +983,34 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy)
static struct ImBuf *generic_fieldscale(struct ImBuf *ibuf, short newx, short newy, struct ImBuf *(*scalefunc)(ImBuf *, short, short) )
{
struct ImBuf *sbuf1, *sbuf2;
/* extern void rectcpy(); */
sbuf1 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, ibuf->depth, IB_rect, 0);
sbuf2 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, ibuf->depth, IB_rect, 0);
sbuf1 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, ibuf->depth, ibuf->flags, 0);
sbuf2 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, ibuf->depth, ibuf->flags, 0);
ibuf->x *= 2;
/* more args needed, 0 assumed... (nzc) */
/* rectop(sbuf1, ibuf, 0, 0, 0, 0, 32767, 32767, rectcpy); */
/* rectop(sbuf2, ibuf, 0, 0, sbuf2->x, 0, 32767, 32767, rectcpy); */
IMB_rectop(sbuf1, ibuf, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectop(sbuf2, ibuf, 0, 0, sbuf2->x, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(sbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
IMB_rectcpy(sbuf2, ibuf, 0, 0, sbuf2->x, 0, ibuf->x, ibuf->y);
imb_freerectImBuf(ibuf);
imb_freerectfloatImBuf(ibuf);
ibuf->x = newx;
ibuf->y = newy;
imb_addrectImBuf(ibuf);
imb_addrectImBuf(ibuf);
if(ibuf->flags & IB_rectfloat)
imb_addrectfloatImBuf(ibuf);
scalefunc(sbuf1, newx, newy / 2);
scalefunc(sbuf2, newx, newy / 2);
ibuf->x *= 2;
/* more args needed, 0 assumed... (nzc) */
/* rectop(ibuf, sbuf1, 0, 0, 0, 0, 32767, 32767, rectcpy); */
/* rectop(ibuf, sbuf2, sbuf2->x, 0, 0, 0, 32767, 32767, rectcpy); */
IMB_rectop(ibuf, sbuf1, 0, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectop(ibuf, sbuf2, sbuf2->x, 0, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(ibuf, sbuf1, 0, 0, 0, 0, sbuf1->x, sbuf1->y);
IMB_rectcpy(ibuf, sbuf2, sbuf2->x, 0, 0, 0, sbuf2->x, sbuf2->y);
ibuf->x /= 2;
@@ -683,9 +1021,7 @@ static struct ImBuf *generic_fieldscale(struct ImBuf *ibuf, short newx, short ne
}
struct ImBuf *IMB_scalefastfieldImBuf(struct ImBuf *ibuf,
short newx,
short newy)
struct ImBuf *IMB_scalefastfieldImBuf(struct ImBuf *ibuf, short newx, short newy)
{
return(generic_fieldscale(ibuf, newx, newy, IMB_scalefastImBuf));
}
@@ -694,3 +1030,4 @@ struct ImBuf *IMB_scalefieldImBuf(struct ImBuf *ibuf, short newx, short newy)
{
return(generic_fieldscale(ibuf, newx, newy, IMB_scaleImBuf));
}

View File

@@ -518,8 +518,8 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, int flags)
if (checktarga(&tga,mem) == 0) return(0);
if (flags & IB_test) ibuf = IMB_allocImBuf(tga.xsize,tga.ysize,tga.pixsize,0,0);
else ibuf = IMB_allocImBuf(tga.xsize,tga.ysize,(tga.pixsize + 0x7) & ~0x7,1,0);
if (flags & IB_test) ibuf = IMB_allocImBuf(tga.xsize,tga.ysize,tga.pixsize, 0, 0);
else ibuf = IMB_allocImBuf(tga.xsize,tga.ysize,(tga.pixsize + 0x7) & ~0x7, IB_rect, 0);
if (ibuf == 0) return(0);
ibuf->ftype = TGA;
@@ -629,7 +629,7 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, int flags)
if (ibuf) {
if (ibuf->rect && (flags & IB_cmap)==0)
IMB_convert_rgba_to_abgr((ibuf->x+ibuf->skipx)*ibuf->y, ibuf->rect);
IMB_convert_rgba_to_abgr(ibuf);
}
return(ibuf);

View File

@@ -399,7 +399,7 @@ struct ImBuf *imb_loadtiff(unsigned char *mem, int size, int flags)
/* close the client layer interface to the in-memory file */
libtiff_TIFFClose(image);
if (G.order == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf->x*ibuf->y, ibuf->rect);
if (G.order == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
/* return successfully */
return (ibuf);

View File

@@ -50,6 +50,10 @@
#include "IMB_anim.h"
#ifdef WITH_OPENEXR
#include "openexr/openexr_api.h"
#endif
#ifdef WITH_QUICKTIME
#include "quicktime_import.h"
#endif
@@ -97,7 +101,9 @@ static int IMB_ispic_name(char *name)
}
if (imb_is_a_png(buf)) return(PNG);
if (imb_is_a_targa(buf)) return(TGA);
#ifdef WITH_OPENEXR
if (imb_is_a_openexr((uchar *)buf)) return(OPENEXR);
#endif
if (imb_is_a_tiff(buf)) return(TIF);
/* radhdr: check if hdr format */

View File

@@ -57,12 +57,15 @@
#include "IMB_bmp.h"
#include "IMB_tiff.h"
#include "IMB_radiance_hdr.h"
#ifdef WITH_OPENEXR
#include "openexr/openexr_api.h"
#endif
#include "IMB_iff.h"
#include "IMB_bitplanes.h"
#include "IMB_divers.h"
short IMB_saveiff(struct ImBuf *ibuf,char *naam,int flags)
short IMB_saveiff(struct ImBuf *ibuf, char *name, int flags)
{
short ok=TRUE,delpl=FALSE;
int file = -1;
@@ -72,28 +75,33 @@ short IMB_saveiff(struct ImBuf *ibuf,char *naam,int flags)
/* Put formats that take a filename here */
if (IS_jpg(ibuf)) {
return imb_savejpeg(ibuf, naam, flags);
return imb_savejpeg(ibuf, name, flags);
}
if (IS_radhdr(ibuf)) {
return imb_savehdr(ibuf, naam, flags);
return imb_savehdr(ibuf, name, flags);
}
if (IS_png(ibuf)) {
return imb_savepng(ibuf,naam,flags);
return imb_savepng(ibuf, name, flags);
}
if (IS_bmp(ibuf)) {
return imb_savebmp(ibuf,naam,flags);
return imb_savebmp(ibuf, name, flags);
}
if (IS_tga(ibuf)) {
return imb_savetarga(ibuf,naam,flags);
return imb_savetarga(ibuf, name, flags);
}
if (IS_iris(ibuf)) {
return imb_saveiris(ibuf,naam,flags);
return imb_saveiris(ibuf, name, flags);
}
if (G.have_libtiff && IS_tiff(ibuf)) {
return imb_savetiff(ibuf,naam,flags);
return imb_savetiff(ibuf, name, flags);
}
#ifdef WITH_OPENEXR
if (IS_openexr(ibuf)) {
return imb_save_openexr_half(ibuf, name, flags);
}
#endif
file = open(naam, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, 0666);
file = open(name, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, 0666);
if (file < 0) return (FALSE);
if (flags & IB_rect){
@@ -103,7 +111,6 @@ short IMB_saveiff(struct ImBuf *ibuf,char *naam,int flags)
}
/* Put formats that take a filehandle here */
ok = imb_start_iff(ibuf,file);
if (IS_amiga(ibuf)){
IMB_flipy(ibuf);

View File

@@ -141,26 +141,26 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_VIEWBUTS 1100
#define B_LOADBGPIC 1001
#define B_BLENDBGPIC 1002
#define B_BGPICBROWSE 1003
#define B_BLENDBGPIC 1002
#define B_BGPICBROWSE 1003
#define B_BGPICTEX 1004
#define B_BGPICCLEAR 1005
#define B_BGPICTEXCLEAR 1006
#define B_BGPICCLEAR 1005
#define B_BGPICTEXCLEAR 1006
#define B_OBJECTPANELROT 1007
#define B_OBJECTPANELMEDIAN 1008
#define B_OBJECTPANELMEDIAN 1008
#define B_ARMATUREPANEL1 1009
#define B_ARMATUREPANEL2 1010
#define B_OBJECTPANELPARENT 1011
#define B_OBJECTPANELPARENT 1011
#define B_OBJECTPANEL 1012
#define B_ARMATUREPANEL3 1013
/* *********************** */
#define B_LAMPBUTS 1200
#define B_LAMPREDRAW 1101
#define B_LAMPREDRAW 1101
#define B_COLLAMP 1102
#define B_TEXCLEARLAMP 1103
#define B_TEXCLEARLAMP 1103
#define B_SBUFF 1104
#define B_SHADBUF 1105
#define B_SHADRAY 1106
@@ -289,7 +289,7 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_PR_PAL169 1612
#define B_PR_D2MAC 1613
#define B_PR_MPEG 1614
#define B_REDRAWDISP 1615
#define B_REDRAWDISP 1615
#define B_SETBROWSE 1616
#define B_CLEARSET 1617
#define B_PR_PRESET 1618
@@ -297,32 +297,33 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_PR_NTSC 1620
#define B_IS_FTYPE 1622
#define B_IS_BACKBUF 1623
#define B_IS_BACKBUF 1623
#define B_PR_PC 1624
#define B_PR_PANO360 1627
#define B_PR_HALFFIELDS 1628
#define B_NEWRENDERPIPE 1629
#define B_R_SCALE 1630
#define B_G_SCALE 1631
#define B_B_SCALE 1632
#define B_USE_R_SCALE 1633
#define B_USE_G_SCALE 1634
#define B_USE_B_SCALE 1635
#define B_EDGECOLSLI 1636
#define B_GAMMASLI 1637
#define B_PR_PANO360 1627
#define B_PR_HALFFIELDS 1628
#define B_NEWRENDERPIPE 1629
#define B_R_SCALE 1630
#define B_G_SCALE 1631
#define B_B_SCALE 1632
#define B_USE_R_SCALE 1633
#define B_USE_G_SCALE 1634
#define B_USE_B_SCALE 1635
#define B_EDGECOLSLI 1636
#define B_GAMMASLI 1637
#define B_FILETYPEMENU 1638
#define B_SELECTCODEC 1639
#define B_FILETYPEMENU 1638
#define B_SELECTCODEC 1639
#define B_RTCHANGED 1640
#define B_SWITCHRENDER 1641
#define B_SWITCHRENDER 1641
#define B_FBUF_REDO 1642
#define B_SET_EDGE 1643
#define B_SET_ZBLUR 1644
#define B_SET_OPENEXR 1645
/* *********************** */
#define B_ARMATUREBUTS 1800
#define B_ARMATUREBUTS 1800
#define B_POSE 1701
/* *********************** */
@@ -342,7 +343,7 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_SETSOLID 2013
#define B_AUTOTEX 2014
#define B_DOCENTRE 2015
#define B_DOCENTRENEW 2016
#define B_DOCENTRENEW 2016
#define B_DOCENTRECURSOR 2017
/* 20 values! */
@@ -367,43 +368,43 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_SPLIT 2056
#define B_REMDOUB 2057
#define B_SUBDIV 2058
#define B_FRACSUBDIV 2059
#define B_FRACSUBDIV 2059
#define B_XSORT 2060
#define B_HASH 2061
#define B_DELSTICKY 2062
#define B_DELVERTCOL 2063
#define B_MAKE_TFACES 2064
#define B_DELVERTCOL 2063
#define B_MAKE_TFACES 2064
#define B_TOSPHERE 2065
#define B_DEL_TFACES 2066
#define B_DEL_TFACES 2066
#define B_NEWVGROUP 2067
#define B_DELVGROUP 2068
#define B_ASSIGNVGROUP 2069
#define B_REMOVEVGROUP 2070
#define B_ASSIGNVGROUP 2069
#define B_REMOVEVGROUP 2070
#define B_SELVGROUP 2071
#define B_DESELVGROUP 2072
#define B_DECIM_FACES 2073
#define B_DECIM_CANCEL 2074
#define B_DECIM_APPLY 2075
#define B_AUTOVGROUP 2076
#define B_SLOWERDRAW 2077
#define B_FASTERDRAW 2078
#define B_VERTEXNOISE 2079
#define B_VERTEXSMOOTH 2080
#define B_MAKESTICKY 2082
#define B_MAKEVERTCOL 2083
#define B_CHROMADEPTH 2084
#define B_DESELVGROUP 2072
#define B_DECIM_FACES 2073
#define B_DECIM_CANCEL 2074
#define B_DECIM_APPLY 2075
#define B_AUTOVGROUP 2076
#define B_SLOWERDRAW 2077
#define B_FASTERDRAW 2078
#define B_VERTEXNOISE 2079
#define B_VERTEXSMOOTH 2080
#define B_MAKESTICKY 2082
#define B_MAKEVERTCOL 2083
#define B_CHROMADEPTH 2084
#define B_DRAWEDGES 2087
#define B_DRAWCREASES 2088
#define B_LINKEDVGROUP 2089
#define B_DRAWCREASES 2088
#define B_LINKEDVGROUP 2089
/* *********************** */
#define B_CURVEBUTS 2200
#define B_CONVERTPOLY 2101
#define B_CONVERTBEZ 2102
#define B_CONVERTBSPL 2103
#define B_CONVERTCARD 2104
#define B_CONVERTNURB 2105
#define B_CONVERTPOLY 2101
#define B_CONVERTBEZ 2102
#define B_CONVERTBSPL 2103
#define B_CONVERTCARD 2104
#define B_CONVERTNURB 2105
#define B_UNIFU 2106
#define B_ENDPU 2107
#define B_BEZU 2108
@@ -416,12 +417,12 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_SETW3 2115
#define B_SETORDER 2116
#define B_MAKEDISP 2117
#define B_SUBDIVCURVE 2118
#define B_SUBDIVCURVE 2118
#define B_SPINNURB 2119
#define B_CU3D 2120
#define B_SETRESOLU 2121
#define B_SETW4 2122
#define B_SUBSURFTYPE 2123
#define B_SUBSURFTYPE 2123
/* *********************** */
#define B_FONTBUTS 2300
@@ -430,16 +431,16 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
#define B_TOUPPER 2202
#define B_SETFONT 2203
#define B_LOADFONT 2204
#define B_TEXTONCURVE 2205
#define B_TEXTONCURVE 2205
#define B_PACKFONT 2206
#define B_LOAD3DTEXT 2207
#define B_LOAD3DTEXT 2207
#define B_LOREM 2208
#define B_FASTFONT 2209
#define B_INSTB 2210
#define B_DELTB 2211
#define B_STYLETOSELB 2212
#define B_STYLETOSELU 2213
#define B_STYLETOSELI 2214
#define B_STYLETOSELB 2212
#define B_STYLETOSELU 2213
#define B_STYLETOSELI 2214
#define B_SETCHAR 2215
#define B_SETUPCHAR 2216
@@ -459,106 +460,106 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
/* *********************** */
#define B_MBALLBUTS 2600
#define B_RECALCMBALL 2501
#define B_RECALCMBALL 2501
/* *********************** */
#define B_LATTBUTS 2700
#define B_RESIZELAT 2601
#define B_DRAWLAT 2602
#define B_LATTCHANGED 2603
#define B_REGULARLAT 2604
#define B_LATTCHANGED 2603
#define B_REGULARLAT 2604
/* *********************** */
#define B_GAMEBUTS 2800
#define B_ADD_PROP 2701
#define B_CHANGE_PROP 2702
#define B_CHANGE_PROP 2702
#define B_ADD_SENS 2703
#define B_CHANGE_SENS 2704
#define B_CHANGE_SENS 2704
#define B_DEL_SENS 2705
#define B_ADD_CONT 2706
#define B_CHANGE_CONT 2707
#define B_CHANGE_CONT 2707
#define B_DEL_CONT 2708
#define B_ADD_ACT 2709
#define B_CHANGE_ACT 2710
#define B_CHANGE_ACT 2710
#define B_DEL_ACT 2711
#define B_SOUNDACT_BROWSE 2712
#define B_SETSECTOR 2713
#define B_SETPROP 2714
#define B_SETACTOR 2715
#define B_SETSECTOR 2713
#define B_SETPROP 2714
#define B_SETACTOR 2715
#define B_SETMAINACTOR 2716
#define B_SETDYNA 2717
#define B_SETDYNA 2717
/* *********************** */
#define B_FPAINTBUTS 2900
#define B_FPAINTBUTS 2900
#define B_VPCOLSLI 2801
#define B_VPGAMMA 2802
#define B_COPY_TF_MODE 2804
#define B_COPY_TF_UV 2805
#define B_COPY_TF_COL 2806
#define B_REDR_3D_IMA 2807
#define B_COPY_TF_MODE 2804
#define B_COPY_TF_UV 2805
#define B_COPY_TF_COL 2806
#define B_REDR_3D_IMA 2807
#define B_SET_VCOL 2808
#define B_COPY_TF_TEX 2814
#define B_TFACE_HALO 2815
#define B_TFACE_BILLB 2816
#define B_COPY_TF_TEX 2814
#define B_TFACE_HALO 2815
#define B_TFACE_BILLB 2816
#define B_SHOWTEX 2832
#define B_ASSIGNMESH 2833
#define B_ASSIGNMESH 2833
#define B_WEIGHT0_0 2840
#define B_WEIGHT1_4 2841
#define B_WEIGHT1_2 2842
#define B_WEIGHT3_4 2843
#define B_WEIGHT1_0 2844
#define B_WEIGHT0_0 2840
#define B_WEIGHT1_4 2841
#define B_WEIGHT1_2 2842
#define B_WEIGHT3_4 2843
#define B_WEIGHT1_0 2844
#define B_OPA1_8 2845
#define B_OPA1_4 2846
#define B_OPA1_2 2847
#define B_OPA3_4 2848
#define B_OPA1_0 2849
#define B_OPA1_8 2845
#define B_OPA1_4 2846
#define B_OPA1_2 2847
#define B_OPA3_4 2848
#define B_OPA1_0 2849
#define B_CLR_WPAINT 2850
#define B_CLR_WPAINT 2850
/* *********************** */
#define B_RADIOBUTS 3000
#define B_RAD_GO 2901
#define B_RAD_INIT 2902
#define B_RAD_LIMITS 2903
#define B_RAD_LIMITS 2903
#define B_RAD_FAC 2904
#define B_RAD_NODELIM 2905
#define B_RAD_NODEFILT 2906
#define B_RAD_FACEFILT 2907
#define B_RAD_NODELIM 2905
#define B_RAD_NODEFILT 2906
#define B_RAD_FACEFILT 2907
#define B_RAD_ADD 2908
#define B_RAD_DELETE 2909
#define B_RAD_COLLECT 2910
#define B_RAD_SHOOTP 2911
#define B_RAD_SHOOTE 2912
#define B_RAD_REPLACE 2913
#define B_RAD_DELETE 2909
#define B_RAD_COLLECT 2910
#define B_RAD_SHOOTP 2911
#define B_RAD_SHOOTE 2912
#define B_RAD_REPLACE 2913
#define B_RAD_DRAW 2914
#define B_RAD_FREE 2915
#define B_RAD_ADDMESH 2916
#define B_RAD_ADDMESH 2916
/* *********************** */
#define B_SCRIPTBUTS 3100
#define B_SCRIPTBUTS 3100
#define B_SCRIPT_ADD 3001
#define B_SCRIPT_DEL 3002
#define B_SCRIPT_TYPE 3003
#define B_SCRIPT_ADD 3001
#define B_SCRIPT_DEL 3002
#define B_SCRIPT_TYPE 3003
/* Scene script buttons */
#define B_SSCRIPT_ADD 3004
#define B_SSCRIPT_DEL 3005
#define B_SSCRIPT_TYPE 3006
#define B_SSCRIPT_ADD 3004
#define B_SSCRIPT_DEL 3005
#define B_SSCRIPT_TYPE 3006
/* *********************** */
#define B_SOUNDBUTS 3200
@@ -629,37 +630,32 @@ enum {
B_UVAUTO_LSCM
};
#define B_EFFECTSBUTS 3500
#define B_EFFECTSBUTS 3500
#define B_AUTOTIMEOFS 3403
#define B_AUTOTIMEOFS 3403
#define B_FRAMEMAP 3404
#define B_NEWEFFECT 3405
#define B_PREVEFFECT 3406
#define B_NEXTEFFECT 3407
#define B_CHANGEEFFECT 3408
#define B_CALCEFFECT 3409
#define B_PREVEFFECT 3406
#define B_NEXTEFFECT 3407
#define B_CHANGEEFFECT 3408
#define B_CALCEFFECT 3409
#define B_DELEFFECT 3410
#define B_RECALCAL 3411
#define B_RECALC_DEFL 3412
#define B_EFFECT_DEP 3413
#define B_RECALC_DEFL 3412
#define B_EFFECT_DEP 3413
#define B_FIELD_DEP 3414
#define B_FIELD_CHANGE 3415
#define B_PAF_SET_VG 3416
#define B_PAF_SET_VG1 3417
#define B_FIELD_CHANGE 3415
#define B_PAF_SET_VG 3416
#define B_PAF_SET_VG1 3417
#define B_MODIFIER_BUTS 3600
#define B_MODIFIER_RECALC 3501
#define B_MODIFIER_REDRAW 3502
/* *********************** */
/* *********************** */
/* BUTTON BUT: > 4000 */
/* BUTTON 4001-4032: layers */
#endif

View File

@@ -405,6 +405,7 @@ typedef struct Scene {
#define R_BMP 20
#define R_RADHDR 21
#define R_TIFF 22
#define R_OPENEXR 23
/* **************** SCENE ********************* */
#define RAD_PHASE_PATCHES 1

View File

@@ -37,10 +37,6 @@
#include <math.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* external modules: */
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
@@ -168,18 +164,18 @@ static void envmap_split_ima(EnvMap *env)
ima->ok= 1;
env->cube[part]= ima;
}
IMB_rectop(env->cube[0]->ibuf, env->ima->ibuf,
0, 0, 0, 0, dx, dx, IMB_rectcpy, 0);
IMB_rectop(env->cube[1]->ibuf, env->ima->ibuf,
0, 0, dx, 0, dx, dx, IMB_rectcpy, 0);
IMB_rectop(env->cube[2]->ibuf, env->ima->ibuf,
0, 0, 2*dx, 0, dx, dx, IMB_rectcpy, 0);
IMB_rectop(env->cube[3]->ibuf, env->ima->ibuf,
0, 0, 0, dx, dx, dx, IMB_rectcpy, 0);
IMB_rectop(env->cube[4]->ibuf, env->ima->ibuf,
0, 0, dx, dx, dx, dx, IMB_rectcpy, 0);
IMB_rectop(env->cube[5]->ibuf, env->ima->ibuf,
0, 0, 2*dx, dx, dx, dx, IMB_rectcpy, 0);
IMB_rectcpy(env->cube[0]->ibuf, env->ima->ibuf,
0, 0, 0, 0, dx, dx);
IMB_rectcpy(env->cube[1]->ibuf, env->ima->ibuf,
0, 0, dx, 0, dx, dx);
IMB_rectcpy(env->cube[2]->ibuf, env->ima->ibuf,
0, 0, 2*dx, 0, dx, dx);
IMB_rectcpy(env->cube[3]->ibuf, env->ima->ibuf,
0, 0, 0, dx, dx, dx);
IMB_rectcpy(env->cube[4]->ibuf, env->ima->ibuf,
0, 0, dx, dx, dx, dx);
IMB_rectcpy(env->cube[5]->ibuf, env->ima->ibuf,
0, 0, 2*dx, dx, dx, dx);
env->ok= 2;
}
}
@@ -414,9 +410,12 @@ static void render_envmap(EnvMap *env)
MTC_Mat4Invert(oldviewinv, R.viewmat);
/* do first, envmap_renderdata copies entire R struct */
if(R.rectz) MEM_freeN(R.rectz); R.rectz= NULL;
if(R.rectot) MEM_freeN(R.rectot); R.rectot= NULL;
if(R.rectftot) MEM_freeN(R.rectftot); R.rectftot= NULL;
if(R.rectz) MEM_freeN(R.rectz);
if(R.rectot) MEM_freeN(R.rectot);
if(R.rectftot) MEM_freeN(R.rectftot);
R.rectftot= NULL;
R.rectz= NULL;
R.rectot= NULL;
/* setup necessary globals */
envmap_renderdata(env);
@@ -478,9 +477,12 @@ static void render_envmap(EnvMap *env)
}
if(R.rectz) MEM_freeN(R.rectz); R.rectz= NULL;
if(R.rectot) MEM_freeN(R.rectot); R.rectot= NULL;
if(R.rectftot) MEM_freeN(R.rectftot); R.rectftot= NULL;
if(R.rectz) MEM_freeN(R.rectz);
if(R.rectot) MEM_freeN(R.rectot);
if(R.rectftot) MEM_freeN(R.rectftot);
R.rectz= NULL;
R.rectot= NULL;
R.rectftot= NULL;
if(RE_local_test_break()) RE_free_envmapdata(env);
else {

View File

@@ -38,10 +38,6 @@
#include <string.h>
#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "blendef.h"
#include "MEM_guardedalloc.h"
@@ -897,6 +893,7 @@ static void yafrayRender(void)
/* float rgba buf */
if (R.rectftot) MEM_freeN(R.rectftot);
if (R.r.mode & R_FBUF) R.rectftot= MEM_callocN(4*sizeof(float)*R.rectx*R.recty, "rectftot");
else R.rectftot = NULL;
// switch must be done before prepareScene()
if (!R.r.YFexportxml)
@@ -1054,6 +1051,7 @@ static void mainRenderLoop(void) /* here the PART and FIELD loops */
if(R.rectftot) MEM_freeN(R.rectftot);
if(R.r.mode & R_FBUF) R.rectftot= MEM_callocN(4*sizeof(float)*R.rectx*R.recty, "rectftot");
else R.rectftot = NULL;
if(R.r.mode & R_MBLUR) {
RE_local_printrenderinfo(0.0, R.osa - blur);

View File

@@ -112,6 +112,10 @@ ifeq ($(WITH_QUICKTIME),true)
CPPFLAGS += -DWITH_QUICKTIME
endif
ifeq ($(WITH_OPENEXR),true)
CPPFLAGS += -DWITH_OPENEXR
endif
ifeq ($(INTERNATIONAL), true)
CPPFLAGS += -DINTERNATIONAL
endif

View File

@@ -979,14 +979,19 @@ static char *imagetype_pup(void)
"HamX", R_HAMX,
"Iris", R_IRIS,
"Iris + Zbuffer", R_IRIZ,
"Radiance HDR", R_RADHDR,
"Radiance HDR", R_RADHDR
#ifdef __sgi
"Movie", R_MOVIE,
,"Movie", R_MOVIE
#endif
"Ftype", R_FTYPE
);
}
#ifdef WITH_OPENEXR
strcpy(formatstring, "|%s %%x%d");
sprintf(appendstring, formatstring, "OpenEXR", R_OPENEXR);
strcat(string, appendstring);
#endif
if (G.have_libtiff) {
strcpy(formatstring, "|%s %%x%d");
sprintf(appendstring, formatstring, "TIFF", R_TIFF);
@@ -1252,7 +1257,14 @@ static void render_panel_format(void)
#endif
uiDefBut(block, BUT,B_SELECTCODEC, "Set codec", 892,yofs,112,20, 0, 0, 0, 0, 0, "Set codec settings for AVI");
}
#ifdef WITH_OPENEXR
} else if (G.scene->r.imtype == R_OPENEXR ) {
if (G.scene->r.quality > 5) G.scene->r.quality = 0;
uiDefButS(block, MENU,B_SET_OPENEXR, "Codec %t|None %x0|Pxr24 (lossy) %x1|ZIP (lossless) %x2|PIZ (lossless) %x3|RLE (lossless) %x4", 892,yofs,112,20, &G.scene->r.quality, 0, 0, 0, 0, "Set codec settings for OpenEXR");
#endif
} else {
if(G.scene->r.quality < 5) G.scene->r.quality = 90; // temp
uiDefButS(block, NUM,B_DIFF, "Quality:", 892,yofs,112,20, &G.scene->r.quality, 10.0, 100.0, 0, 0, "Quality setting for JPEG images, AVI Jpeg and SGI movies");
}
uiDefButS(block, NUM,B_FRAMEMAP,"Frs/sec:", 1006,yofs,113,20, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second");

View File

@@ -34,10 +34,6 @@
#include <math.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
@@ -1023,7 +1019,8 @@ void face_borderselect()
Mesh *me;
TFace *tface;
rcti rect;
unsigned int *rectm, *rt;
struct ImBuf *ibuf;
unsigned int *rt;
int a, sx, sy, index, val;
char *selar;
@@ -1046,9 +1043,10 @@ void face_borderselect()
sy= (rect.ymax-rect.ymin+1);
if(sx*sy<=0) return;
rt=rectm= MEM_mallocN(sizeof(int)*sx*sy, "selrect");
glReadPixels(rect.xmin+curarea->winrct.xmin, rect.ymin+curarea->winrct.ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, rectm);
if(G.order==B_ENDIAN) IMB_convert_rgba_to_abgr(sx*sy, rectm);
ibuf = IMB_allocImBuf(sx,sy,32,0,0);
rt = ibuf->rect;
glReadPixels(rect.xmin+curarea->winrct.xmin, rect.ymin+curarea->winrct.ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
if(G.order==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
a= sx*sy;
while(a--) {
@@ -1070,7 +1068,7 @@ void face_borderselect()
}
}
MEM_freeN(rectm);
IMB_freeImBuf(ibuf);
MEM_freeN(selar);
BIF_undo_push("Border Select UV face");

View File

@@ -40,10 +40,6 @@ editmesh_mods.c, UI level access, no geometry changes
#include <string.h>
#include <math.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "MEM_guardedalloc.h"
#include "MTC_matrixops.h"
@@ -92,6 +88,7 @@ editmesh_mods.c, UI level access, no geometry changes
#include "BSE_edit.h"
#include "BSE_view.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "mydevice.h"
@@ -155,11 +152,12 @@ static unsigned int sample_backbuf(int x, int y)
}
/* reads full rect, converts indices */
static unsigned int *read_backbuf(short xmin, short ymin, short xmax, short ymax)
struct ImBuf *read_backbuf(short xmin, short ymin, short xmax, short ymax)
{
unsigned int *dr, *buf;
unsigned int *dr, *rd;
struct ImBuf *ibuf, *ibuf1;
int a;
short xminc, yminc, xmaxc, ymaxc;
short xminc, yminc, xmaxc, ymaxc, xs, ys;
/* clip */
if(xmin<0) xminc= 0; else xminc= xmin;
@@ -170,55 +168,49 @@ static unsigned int *read_backbuf(short xmin, short ymin, short xmax, short ymax
if(ymax>=curarea->winy) ymaxc= curarea->winy-1; else ymaxc= ymax;
if(yminc > ymaxc) return NULL;
buf= MEM_mallocN( (xmaxc-xminc+1)*(ymaxc-yminc+1)*sizeof(int), "sample rect");
ibuf= IMB_allocImBuf((xmaxc-xminc+1),(ymaxc-yminc+1),32,IB_rect,0);
check_backbuf(); // actually not needed for apple
#ifdef __APPLE__
glReadBuffer(GL_AUX0);
#endif
glReadPixels(curarea->winrct.xmin+xminc, curarea->winrct.ymin+yminc, (xmaxc-xminc+1), (ymaxc-yminc+1), GL_RGBA, GL_UNSIGNED_BYTE, buf);
glReadPixels(curarea->winrct.xmin+xminc, curarea->winrct.ymin+yminc, (xmaxc-xminc+1), (ymaxc-yminc+1), GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
glReadBuffer(GL_BACK);
if(G.order==B_ENDIAN) IMB_convert_rgba_to_abgr((xmaxc-xminc+1)*(ymaxc-yminc+1), buf);
if(G.order==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
a= (xmaxc-xminc+1)*(ymaxc-yminc+1);
dr= buf;
dr= ibuf->rect;
while(a--) {
if(*dr) *dr= framebuffer_to_index(*dr);
dr++;
}
/* put clipped result back, if needed */
if(xminc==xmin && xmaxc==xmax && yminc==ymin && ymaxc==ymax) return buf;
else {
unsigned int *buf1= MEM_callocN( (xmax-xmin+1)*(ymax-ymin+1)*sizeof(int), "sample rect2");
unsigned int *rd;
short xs, ys;
rd= buf;
dr= buf1;
if(xminc==xmin && xmaxc==xmax && yminc==ymin && ymaxc==ymax) return ibuf;
ibuf1= IMB_allocImBuf( (xmax-xmin+1),(ymax-ymin+1),32,IB_rect,0);
rd= ibuf->rect;
dr= ibuf1->rect;
for(ys= ymin; ys<=ymax; ys++) {
for(xs= xmin; xs<=xmax; xs++, dr++) {
if( xs>=xminc && xs<=xmaxc && ys>=yminc && ys<=ymaxc) {
*dr= *rd;
rd++;
}
for(ys= ymin; ys<=ymax; ys++) {
for(xs= xmin; xs<=xmax; xs++, dr++) {
if( xs>=xminc && xs<=xmaxc && ys>=yminc && ys<=ymaxc) {
*dr= *rd;
rd++;
}
}
MEM_freeN(buf);
return buf1;
}
return buf;
IMB_freeImBuf(ibuf);
return ibuf1;
}
/* smart function to sample a rect spiralling outside, nice for backbuf selection */
static unsigned int sample_backbuf_rect(short mval[2], int size, unsigned int min, unsigned int max, short *dist)
{
unsigned int *buf, *bufmin, *bufmax;
struct ImBuf *buf;
unsigned int *bufmin, *bufmax, *tbuf;
int minx, miny;
int a, b, rc, nr, amount, dirvec[4][2];
short distance=0;
@@ -229,8 +221,7 @@ static unsigned int sample_backbuf_rect(short mval[2], int size, unsigned int mi
minx = mval[0]-(amount+1);
miny = mval[1]-(amount+1);
buf = read_backbuf(minx, miny, minx+size-1, miny+size-1);
if (!buf)
return 0;
if (!buf) return 0;
rc= 0;
@@ -239,23 +230,24 @@ static unsigned int sample_backbuf_rect(short mval[2], int size, unsigned int mi
dirvec[2][0]= -1; dirvec[2][1]= 0;
dirvec[3][0]= 0; dirvec[3][1]= size;
bufmin= buf;
bufmax= buf+ size*size;
buf+= amount*size+ amount;
bufmin = buf->rect;
tbuf = buf->rect;
bufmax = buf->rect + size*size;
tbuf+= amount*size+ amount;
for(nr=1; nr<=size; nr++) {
for(a=0; a<2; a++) {
for(b=0; b<nr; b++, distance++) {
if (*buf && *buf>=min && *buf<max) {
if (*tbuf && *tbuf>=min && *tbuf<max) {
*dist= (short) sqrt( (float)distance ); // XXX, this distance is wrong - zr
index = *buf - min+1; // messy yah, but indices start at 1
index = *tbuf - min+1; // messy yah, but indices start at 1
goto exit;
}
buf+= (dirvec[rc][0]+dirvec[rc][1]);
tbuf+= (dirvec[rc][0]+dirvec[rc][1]);
if(buf<bufmin || buf>=bufmax) {
if(tbuf<bufmin || tbuf>=bufmax) {
goto exit;
}
}
@@ -265,7 +257,7 @@ static unsigned int sample_backbuf_rect(short mval[2], int size, unsigned int mi
}
exit:
MEM_freeN(bufmin);
IMB_freeImBuf(buf);
return index;
}
@@ -322,14 +314,17 @@ static void draw_triangulated(short mcords[][2], short tot)
/* returns if all is OK */
int EM_init_backbuf_border(short xmin, short ymin, short xmax, short ymax)
{
unsigned int *buf, *dr;
struct ImBuf *buf;
unsigned int *dr;
int a;
if(G.obedit==NULL || G.vd->drawtype<OB_SOLID || (G.vd->flag & V3D_ZBUF_SELECT)==0) return 0;
if(em_vertoffs==0) return 0;
dr= buf= read_backbuf(xmin, ymin, xmax, ymax);
buf= read_backbuf(xmin, ymin, xmax, ymax);
if(buf==NULL) return 0;
dr = buf->rect;
/* build selection lookup */
selbuf= MEM_callocN(em_vertoffs+1, "selbuf");
@@ -340,7 +335,7 @@ int EM_init_backbuf_border(short xmin, short ymin, short xmax, short ymax)
selbuf[*dr]= 1;
dr++;
}
MEM_freeN(buf);
IMB_freeImBuf(buf);
return 1;
}
@@ -366,7 +361,8 @@ void EM_free_backbuf(void)
*/
int EM_mask_init_backbuf_border(short mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax)
{
unsigned int *buf, *bufmask, *dr, *drm;
unsigned int *dr, *drm;
struct ImBuf *buf, *bufmask;
int a;
/* method in use for face selecting too */
@@ -378,9 +374,11 @@ int EM_mask_init_backbuf_border(short mcords[][2], short tot, short xmin, short
if(em_vertoffs==0) return 0;
dr= buf= read_backbuf(xmin, ymin, xmax, ymax);
buf= read_backbuf(xmin, ymin, xmax, ymax);
if(buf==NULL) return 0;
dr = buf->rect;
/* draw the mask */
#ifdef __APPLE__
glDrawBuffer(GL_AUX0);
@@ -403,7 +401,8 @@ int EM_mask_init_backbuf_border(short mcords[][2], short tot, short xmin, short
glDrawBuffer(GL_BACK);
/* grab mask */
drm= bufmask= read_backbuf(xmin, ymin, xmax, ymax);
bufmask= read_backbuf(xmin, ymin, xmax, ymax);
drm = bufmask->rect;
if(bufmask==NULL) return 0; // only when mem alloc fails, go crash somewhere else!
/* build selection lookup */
@@ -414,8 +413,8 @@ int EM_mask_init_backbuf_border(short mcords[][2], short tot, short xmin, short
if(*dr>0 && *dr<=em_vertoffs && *drm==0) selbuf[*dr]= 1;
dr++; drm++;
}
MEM_freeN(buf);
MEM_freeN(bufmask);
IMB_freeImBuf(buf);
IMB_freeImBuf(bufmask);
return 1;
}
@@ -423,7 +422,8 @@ int EM_mask_init_backbuf_border(short mcords[][2], short tot, short xmin, short
/* circle shaped sample area */
int EM_init_backbuf_circle(short xs, short ys, short rads)
{
unsigned int *buf, *dr;
struct ImBuf *buf;
unsigned int *dr;
short xmin, ymin, xmax, ymax, xc, yc;
int radsq;
@@ -437,8 +437,10 @@ int EM_init_backbuf_circle(short xs, short ys, short rads)
xmin= xs-rads; xmax= xs+rads;
ymin= ys-rads; ymax= ys+rads;
dr= buf= read_backbuf(xmin, ymin, xmax, ymax);
buf= read_backbuf(xmin, ymin, xmax, ymax);
if(buf==NULL) return 0;
dr = buf->rect;
/* build selection lookup */
selbuf= MEM_callocN(em_vertoffs+1, "selbuf");
@@ -451,7 +453,7 @@ int EM_init_backbuf_circle(short xs, short ys, short rads)
}
}
MEM_freeN(buf);
IMB_freeImBuf(buf);
return 1;
}

View File

@@ -502,10 +502,13 @@ void test_flags_file(SpaceFile *sfile)
(BLI_testextensie(file->relname, ".tif")
|| BLI_testextensie(file->relname, ".tiff"))) {
file->flags |= IMAGEFILE;
} else if (BLI_testextensie(file->relname, ".exr")) {
file->flags |= IMAGEFILE;
} else if (G.have_quicktime){
if( BLI_testextensie(file->relname, ".jpg")
|| BLI_testextensie(file->relname, ".jpeg")
|| BLI_testextensie(file->relname, ".hdr")
|| BLI_testextensie(file->relname, ".exr")
|| BLI_testextensie(file->relname, ".tga")
|| BLI_testextensie(file->relname, ".rgb")
|| BLI_testextensie(file->relname, ".bmp")
@@ -532,7 +535,8 @@ void test_flags_file(SpaceFile *sfile)
}
} else { // no quicktime
if(BLI_testextensie(file->relname, ".jpg")
|| BLI_testextensie(file->relname, ".hdr")
|| BLI_testextensie(file->relname, ".hdr")
|| BLI_testextensie(file->relname, ".exr")
|| BLI_testextensie(file->relname, ".tga")
|| BLI_testextensie(file->relname, ".rgb")
|| BLI_testextensie(file->relname, ".bmp")

View File

@@ -34,10 +34,6 @@
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef WIN32
#include <unistd.h>
#else
@@ -538,7 +534,7 @@ void get_next_image(SpaceImaSel *simasel)
/* the whole cmap system is wacko */
if (G.order==B_ENDIAN)
IMB_convert_rgba_to_abgr(ima->dw*ima->dh, ibuf->rect);
IMB_convert_rgba_to_abgr(ibuf);
ibuf->mincol = 0;
ibuf->maxcol = 256;
@@ -555,7 +551,7 @@ void get_next_image(SpaceImaSel *simasel)
longtochar(ima->pict_rect, ibuf->rect, size);
IMB_applycmap(ibuf);
IMB_convert_rgba_to_abgr(size, ibuf->rect);
IMB_convert_rgba_to_abgr(ibuf);
if (ima->pict) IMB_freeImBuf(ima->pict);
ima->pict = ibuf;
@@ -797,7 +793,7 @@ void get_pib_file(SpaceImaSel *simasel)
ima->pict->cmap = simasel->cmap->cmap;
ima->pict->maxcol = 256;
IMB_applycmap(ima->pict);
IMB_convert_rgba_to_abgr(size, ima->pict->rect);
IMB_convert_rgba_to_abgr(ima->pict);
}
ima->selected = 0;
ima->selectable = 0;

View File

@@ -733,8 +733,11 @@ void BIF_icon_draw(float x, float y, int icon_id)
ui_rasterpos_safe(x, y, di->aspect);
if(di->w<1 || di->h<1) {
printf("what the heck!\n");
}
/* di->rect contains image in 'rendersize', we only scale if needed */
if(di->rw!=di->w && di->rh!=di->h) {
else if(di->rw!=di->w && di->rh!=di->h) {
ImBuf *ima;
/* first allocate imbuf for scaling and copy preview into it */
ima = IMB_allocImBuf(di->rw, di->rh, 32, IB_rect, 0);

View File

@@ -87,6 +87,9 @@ void write_screendump(char *name)
else if(G.scene->r.imtype==R_PNG) ibuf->ftype= PNG;
else if((G.have_libtiff) &&
(G.scene->r.imtype==R_TIFF)) ibuf->ftype= TIF;
#ifdef WITH_OPENEXR
else if(G.scene->r.imtype==R_OPENEXR) ibuf->ftype= OPENEXR;
#endif
else if(G.scene->r.imtype==R_HAMX) ibuf->ftype= AN_hamx;
else if(ELEM5(G.scene->r.imtype, R_MOVIE, R_AVICODEC, R_AVIRAW, R_AVIJPEG, R_JPEG90)) {
ibuf->ftype= JPG|G.scene->r.quality;

View File

@@ -34,10 +34,6 @@
#include <math.h>
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "MEM_guardedalloc.h"
#include "PIL_dynlib.h"
@@ -1655,19 +1651,19 @@ void do_effect(int cfra, Sequence *seq, StripElem *se)
if(cp) strncpy(cp, seq->name+2, 22);
if (seq->plugin->version<=2) {
if(se1->ibuf) IMB_convert_rgba_to_abgr(se1->ibuf->x*se1->ibuf->y, se1->ibuf->rect);
if(se2->ibuf) IMB_convert_rgba_to_abgr(se2->ibuf->x*se2->ibuf->y, se2->ibuf->rect);
if(se3->ibuf) IMB_convert_rgba_to_abgr(se3->ibuf->x*se3->ibuf->y, se3->ibuf->rect);
if(se1->ibuf) IMB_convert_rgba_to_abgr(se1->ibuf);
if(se2->ibuf) IMB_convert_rgba_to_abgr(se2->ibuf);
if(se3->ibuf) IMB_convert_rgba_to_abgr(se3->ibuf);
}
((SeqDoit)seq->plugin->doit)(seq->plugin->data, fac, facf, x, y,
se1->ibuf, se2->ibuf, se->ibuf, se3->ibuf);
if (seq->plugin->version<=2) {
if(se1->ibuf) IMB_convert_rgba_to_abgr(se1->ibuf->x*se1->ibuf->y, se1->ibuf->rect);
if(se2->ibuf) IMB_convert_rgba_to_abgr(se2->ibuf->x*se2->ibuf->y, se2->ibuf->rect);
if(se3->ibuf) IMB_convert_rgba_to_abgr(se3->ibuf->x*se3->ibuf->y, se3->ibuf->rect);
IMB_convert_rgba_to_abgr(se->ibuf->x*se->ibuf->y, se->ibuf->rect);
if(se1->ibuf) IMB_convert_rgba_to_abgr(se1->ibuf);
if(se2->ibuf) IMB_convert_rgba_to_abgr(se2->ibuf);
if(se3->ibuf) IMB_convert_rgba_to_abgr(se3->ibuf);
IMB_convert_rgba_to_abgr(se->ibuf);
}
if((G.f & G_PLAYANIM)==0) waitcursor(0);

View File

@@ -147,13 +147,6 @@ void schrijfplaatje(char *name)
unsigned int *temprect=0;
char str[FILE_MAXDIR+FILE_MAXFILE];
/* radhdr: temporary call for direct float buffer save for HDR format */
if ((R.r.imtype==R_RADHDR) && (R.rectftot))
{
imb_savehdr_fromfloat(R.rectftot, name, R.rectx, R.recty);
return;
}
/* has RGBA been set? If so: use alpha channel for color zero */
IMB_alpha_to_col0(FALSE);
@@ -188,7 +181,7 @@ void schrijfplaatje(char *name)
if(ibuf) {
ibuf->rect= (unsigned int *) R.rectot;
// ibuf->rect_float = R.rectftot;
ibuf->rect_float = R.rectftot;
if(R.r.planes == 8) IMB_cspace(ibuf, rgb_to_bw);
@@ -205,8 +198,6 @@ void schrijfplaatje(char *name)
}
}
else if(R.r.imtype==R_RADHDR) {
/* radhdr: save hdr from rgba buffer, not really recommended, probably mistake, so warn user */
error("Will save, but you might want to enable the floatbuffer to save a real HDRI...");
ibuf->ftype= RADHDR;
}
else if(R.r.imtype==R_PNG) {
@@ -218,6 +209,11 @@ void schrijfplaatje(char *name)
else if((G.have_libtiff) && (R.r.imtype==R_TIFF)) {
ibuf->ftype= TIF;
}
#ifdef WITH_OPENEXR
else if(R.r.imtype==R_OPENEXR) {
ibuf->ftype= OPENEXR;
}
#endif
else if((R.r.imtype==R_TARGA) || (R.r.imtype==R_PNG)) {
ibuf->ftype= TGA;
}
@@ -500,6 +496,10 @@ int save_image_filesel_str(char *str)
if (G.have_libtiff) {
strcpy(str, "Save TIFF"); return 1;
}
#ifdef WITH_OPENEXR
case R_OPENEXR:
strcpy(str, "Save OpenEXR"); return 1;
#endif
case R_TARGA:
strcpy(str, "Save Targa"); return 1;
case R_RAWTGA:

View File

@@ -33,10 +33,6 @@
#include <math.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef WIN32
#include <io.h>
#else
@@ -46,6 +42,7 @@
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
@@ -599,7 +596,8 @@ static void vpaint_blend( unsigned int *col, unsigned int *colorig, unsigned int
static int sample_backbuf_area(int x, int y, float size)
{
unsigned int rect[129*129], *rt;
unsigned int *rt;
struct ImBuf *ibuf;
int x1, y1, x2, y2, a, tot=0, index;
if(totvpaintundo>=MAXINDEX) return 0;
@@ -617,12 +615,15 @@ static int sample_backbuf_area(int x, int y, float size)
#ifdef __APPLE__
glReadBuffer(GL_AUX0);
#endif
glReadPixels(x1+curarea->winrct.xmin, y1+curarea->winrct.ymin, x2-x1+1, y2-y1+1, GL_RGBA, GL_UNSIGNED_BYTE, rect);
ibuf = IMB_allocImBuf(size,size,32,IB_rect,0);
glReadPixels(x1+curarea->winrct.xmin, y1+curarea->winrct.ymin, x2-x1+1, y2-y1+1, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
glReadBuffer(GL_BACK);
if(G.order==B_ENDIAN) IMB_convert_rgba_to_abgr( (int)(4*size*size), rect);
if(G.order==B_ENDIAN) {
IMB_convert_rgba_to_abgr(ibuf);
}
rt= rect;
rt= ibuf->rect;
size= (y2-y1)*(x2-x1);
if(size<=0) return 0;
@@ -642,6 +643,8 @@ static int sample_backbuf_area(int x, int y, float size)
for(a=1; a<=totvpaintundo; a++) {
if(indexar[a]) indexar[tot++]= a;
}
IMB_freeImBuf(ibuf);
return tot;
}

View File

@@ -63,6 +63,11 @@ int BIF_write_ibuf(ImBuf *ibuf, char *name)
else if ((G.have_libtiff) && (G.scene->r.imtype==R_TIFF)) {
ibuf->ftype= TIF;
}
#ifdef WITH_OPENEXR
else if (G.scene->r.imtype==R_OPENEXR) {
ibuf->ftype= OPENEXR;
}
#endif
else if ((G.scene->r.imtype==R_TARGA) || (G.scene->r.imtype==R_PNG)) {
// fall back to Targa if PNG writing is not supported
ibuf->ftype= TGA;
@@ -105,18 +110,12 @@ void BIF_save_envmap(EnvMap *env, char *str)
dx= env->cube[0]->ibuf->x;
ibuf= IMB_allocImBuf(3*dx, 2*dx, 24, IB_rect, 0);
IMB_rectop(ibuf, env->cube[0]->ibuf,
0, 0, 0, 0, dx, dx, IMB_rectcpy, 0);
IMB_rectop(ibuf, env->cube[1]->ibuf,
dx, 0, 0, 0, dx, dx, IMB_rectcpy, 0);
IMB_rectop(ibuf, env->cube[2]->ibuf,
2*dx, 0, 0, 0, dx, dx, IMB_rectcpy, 0);
IMB_rectop(ibuf, env->cube[3]->ibuf,
0, dx, 0, 0, dx, dx, IMB_rectcpy, 0);
IMB_rectop(ibuf, env->cube[4]->ibuf,
dx, dx, 0, 0, dx, dx, IMB_rectcpy, 0);
IMB_rectop(ibuf, env->cube[5]->ibuf,
2*dx, dx, 0, 0, dx, dx, IMB_rectcpy, 0);
IMB_rectcpy(ibuf, env->cube[0]->ibuf, 0, 0, 0, 0, dx, dx);
IMB_rectcpy(ibuf, env->cube[1]->ibuf, dx, 0, 0, 0, dx, dx);
IMB_rectcpy(ibuf, env->cube[2]->ibuf, 2*dx, 0, 0, 0, dx, dx);
IMB_rectcpy(ibuf, env->cube[3]->ibuf, 0, dx, 0, 0, dx, dx);
IMB_rectcpy(ibuf, env->cube[4]->ibuf, dx, dx, 0, 0, dx, dx);
IMB_rectcpy(ibuf, env->cube[5]->ibuf, 2*dx, dx, 0, 0, dx, dx);
BIF_write_ibuf(ibuf, str);
IMB_freeImBuf(ibuf);

View File

@@ -30,10 +30,6 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef __sgi
#include <unistd.h>
@@ -364,6 +360,7 @@ void append_movie(int cfra)
char name[FILE_MAXDIR+FILE_MAXFILE];
const char *string;
int fd;
float col[4] = {0.0,0.0,0.0,0.0};
set_sfra_efra();
make_movie_name(name);
@@ -377,28 +374,28 @@ void append_movie(int cfra)
if (ibuf->x != mv_outx || ibuf->y != mv_outy) {
tbuf = IMB_allocImBuf(mv_outx, mv_outy, 32, IB_rect, 0);
IMB_rectoptot(tbuf, 0, IMB_rectfill, 0x00);
IMB_rectfill(tbuf,col);
ofsx = (tbuf->x - ibuf->x) / 2;
ofsy = (tbuf->y - ibuf->y) / 2;
if (numfields == 2) ofsy &= ~1;
IMB_rectop(tbuf, ibuf, ofsx, ofsy, 0, 0, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(tbuf, ibuf, ofsx, ofsy, 0, 0, ibuf->x, ibuf->y);
IMB_freeImBuf(ibuf);
strcpy(tbuf->name, ibuf->name);
ibuf = tbuf;
}
IMB_convert_rgba_to_abgr(ibuf->x*ibuf->y, ibuf->rect);
IMB_convert_rgba_to_abgr(ibuf);
if (numfields == 2) {
if (ntsc) {
IMB_rectop(ibuf, ibuf, 0, 0, 0, 1, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(ibuf, ibuf, 0, 0, 0, 1, ibuf->x, ibuf->y);
IMB_flipy(ibuf);
IMB_de_interlace(ibuf);
if (ntsc) IMB_rectop(ibuf, ibuf, 0, 0, 0, 1, 32767, 32767, IMB_rectcpy, 0);
if (ntsc) IMB_rectcpy(ibuf, ibuf, 0, 0, 0, 1, ibuf->x, ibuf->y);
} else {
IMB_flipy(ibuf);
IMB_rectop(ibuf, ibuf, 0, 0, 0, 1, 32767, 32767, IMB_rectcpy, 0);
IMB_rectcpy(ibuf, ibuf, 0, 0, 0, 1, ibuf->x, ibuf->y);
IMB_de_interlace(ibuf);
}
}