Blender V2.61 - r43446
Defines | Functions

imbuf_cocoa.m File Reference

#include <stdint.h>
#include <string.h>
#import <Cocoa/Cocoa.h>
#include "imbuf.h"
#include "IMB_cocoa.h"
#include "BKE_global.h"
#include "BKE_colortools.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "IMB_allocimbuf.h"

Go to the source code of this file.

Defines

#define FTOUSHORT(val)   ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f))
#define IMB_TIFF_NCB   4

Functions

struct ImBufimb_cocoaLoadImage (unsigned char *mem, int size, int flags)
short imb_cocoaSaveImage (struct ImBuf *ibuf, char *name, int flags)
int imb_is_a_tiff (void *mem)

Define Documentation

#define FTOUSHORT (   val)    ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f))

Saves an image to a file.

ImBuf structures with 1, 3 or 4 bytes per pixel (GRAY, RGB, RGBA respectively) are accepted, and interpreted correctly.

Accepted formats: TIFF, GIF, BMP, PNG, JPEG, JPEG2000

Parameters:
ibuf,:Image buffer.
name,:Name of the image file to create.
flags,:Currently largely ignored.
Returns:
: 1 if the function is successful, 0 on failure.

Definition at line 207 of file imbuf_cocoa.m.

Referenced by imb_cocoaSaveImage().

#define IMB_TIFF_NCB   4

Checks whether a given memory buffer contains a TIFF file.

FIXME: Possible memory leak if mem is less than IMB_TIFF_NCB bytes long. However, changing this will require up-stream modifications.

This method uses the format identifiers from: http://www.faqs.org/faqs/graphics/fileformats-faq/part4/section-9.html The first four bytes of big-endian and little-endian TIFF files respectively are (hex): 4d 4d 00 2a 49 49 2a 00 Note that TIFF files on *any* platform can be either big- or little-endian; it's not platform-specific.

AFAICT, libtiff doesn't provide a method to do this automatically, and hence my manual comparison. - Jonathan Merritt (lancelet) 4th Sept 2005.

Definition at line 378 of file imbuf_cocoa.m.

Referenced by imb_is_a_tiff().


Function Documentation

struct ImBuf* imb_cocoaLoadImage ( unsigned char *  mem,
int  size,
int  flags 
) [read]

Provides image file loading and saving for Blender, via Cocoa. Loads an image from the supplied buffer

Loads any Core Graphics supported type Currently is : TIFF, BMP, JPEG, GIF, PNG, DIB, ICO, and various RAW formats

Parameters:
mem,:Memory containing the bitmap image
size,:Size of the mem buffer.
flags,:If flags has IB_test set then the file is not actually loaded, but all other operations take place.
Returns:
: A newly allocated ImBuf structure if successful, otherwise NULL.

Definition at line 63 of file imbuf_cocoa.m.

References B_ENDIAN, data, ENDIAN_ORDER, ImBuf::ftype, IB_PROFILE_SRGB, IB_test, imb_addrectImBuf(), IMB_allocImBuf(), IMB_convert_rgba_to_abgr(), NULL, ImBuf::profile, ImBuf::rect, ImBuf::x, and ImBuf::y.

short imb_cocoaSaveImage ( struct ImBuf ibuf,
char *  name,
int  flags 
)
int imb_is_a_tiff ( void *  mem)

Definition at line 379 of file imbuf_cocoa.m.

References IMB_TIFF_NCB.