Cleanup: use const for Imbuf file types
This commit is contained in:
parent
924f31e54f
commit
3dfce097e4
|
@ -40,7 +40,7 @@ typedef struct ImFileType {
|
|||
|
||||
int (*is_a)(unsigned char *buf);
|
||||
int (*is_a_filepath)(const char *name);
|
||||
int (*ftype)(struct ImFileType *type, struct ImBuf *ibuf);
|
||||
int (*ftype)(const struct ImFileType *type, struct ImBuf *ibuf);
|
||||
struct ImBuf *(*load)(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]);
|
||||
struct ImBuf *(*load_filepath)(const char *name, int flags, char colorspace[IM_MAX_SPACE]);
|
||||
int (*save)(struct ImBuf *ibuf, const char *name, int flags);
|
||||
|
@ -51,8 +51,8 @@ typedef struct ImFileType {
|
|||
int default_save_role;
|
||||
} ImFileType;
|
||||
|
||||
extern ImFileType IMB_FILE_TYPES[];
|
||||
extern ImFileType *IMB_FILE_TYPES_LAST;
|
||||
extern const ImFileType IMB_FILE_TYPES[];
|
||||
extern const ImFileType *IMB_FILE_TYPES_LAST;
|
||||
|
||||
void imb_filetypes_init(void);
|
||||
void imb_filetypes_exit(void);
|
||||
|
|
|
@ -1948,7 +1948,7 @@ ImBuf *IMB_colormanagement_imbuf_for_write(ImBuf *ibuf, bool save_as_render, boo
|
|||
|
||||
if (do_colormanagement) {
|
||||
bool make_byte = false;
|
||||
ImFileType *type;
|
||||
const ImFileType *type;
|
||||
|
||||
/* for proper check whether byte buffer is required by a format or not
|
||||
* should be pretty safe since this image buffer is supposed to be used for
|
||||
|
@ -2457,7 +2457,7 @@ const char *IMB_colormanagement_colorspace_get_indexed_name(int index)
|
|||
|
||||
void IMB_colormanagment_colorspace_from_ibuf_ftype(ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf)
|
||||
{
|
||||
ImFileType *type;
|
||||
const ImFileType *type;
|
||||
|
||||
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
|
||||
if (type->save && type->ftype(type, ibuf)) {
|
||||
|
|
|
@ -51,17 +51,17 @@
|
|||
#include "quicktime_import.h"
|
||||
#endif
|
||||
|
||||
static int imb_ftype_default(ImFileType *type, ImBuf *ibuf)
|
||||
static int imb_ftype_default(const ImFileType *type, ImBuf *ibuf)
|
||||
{
|
||||
return (ibuf->ftype & type->filetype);
|
||||
}
|
||||
static int imb_ftype_iris(ImFileType *type, ImBuf *ibuf)
|
||||
static int imb_ftype_iris(const ImFileType *type, ImBuf *ibuf)
|
||||
{
|
||||
(void)type;
|
||||
return (ibuf->ftype == IMAGIC);
|
||||
}
|
||||
|
||||
ImFileType IMB_FILE_TYPES[] = {
|
||||
const ImFileType IMB_FILE_TYPES[] = {
|
||||
{NULL, NULL, imb_is_a_jpeg, NULL, imb_ftype_default, imb_load_jpeg, NULL, imb_savejpeg, NULL, 0, JPG, COLOR_ROLE_DEFAULT_BYTE},
|
||||
{NULL, NULL, imb_is_a_png, NULL, imb_ftype_default, imb_loadpng, NULL, imb_savepng, NULL, 0, PNG, COLOR_ROLE_DEFAULT_BYTE},
|
||||
{NULL, NULL, imb_is_a_bmp, NULL, imb_ftype_default, imb_bmp_decode, NULL, imb_savebmp, NULL, 0, BMP, COLOR_ROLE_DEFAULT_BYTE},
|
||||
|
@ -92,11 +92,11 @@ ImFileType IMB_FILE_TYPES[] = {
|
|||
{NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0}
|
||||
};
|
||||
|
||||
ImFileType *IMB_FILE_TYPES_LAST = &IMB_FILE_TYPES[sizeof(IMB_FILE_TYPES) / sizeof(ImFileType) - 1];
|
||||
const ImFileType *IMB_FILE_TYPES_LAST = &IMB_FILE_TYPES[sizeof(IMB_FILE_TYPES) / sizeof(ImFileType) - 1];
|
||||
|
||||
void imb_filetypes_init(void)
|
||||
{
|
||||
ImFileType *type;
|
||||
const ImFileType *type;
|
||||
|
||||
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++)
|
||||
if (type->init)
|
||||
|
@ -109,7 +109,7 @@ void imb_filetypes_init(void)
|
|||
|
||||
void imb_filetypes_exit(void)
|
||||
{
|
||||
ImFileType *type;
|
||||
const ImFileType *type;
|
||||
|
||||
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++)
|
||||
if (type->exit)
|
||||
|
|
|
@ -103,7 +103,7 @@ static void imb_handle_alpha(ImBuf *ibuf, int flags, char colorspace[IM_MAX_SPAC
|
|||
ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
ImFileType *type;
|
||||
const ImFileType *type;
|
||||
char effective_colorspace[IM_MAX_SPACE] = "";
|
||||
|
||||
if (mem == NULL) {
|
||||
|
@ -133,7 +133,7 @@ ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, char co
|
|||
static ImBuf *IMB_ibImageFromFile(const char *filepath, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
ImFileType *type;
|
||||
const ImFileType *type;
|
||||
char effective_colorspace[IM_MAX_SPACE] = "";
|
||||
|
||||
if (colorspace)
|
||||
|
@ -257,7 +257,7 @@ ImBuf *IMB_testiffname(const char *filepath, int flags)
|
|||
|
||||
static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int *rect)
|
||||
{
|
||||
ImFileType *type;
|
||||
const ImFileType *type;
|
||||
unsigned char *mem;
|
||||
size_t size;
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ int IMB_ispic_type(const char *name)
|
|||
#define HEADER_SIZE 64
|
||||
|
||||
unsigned char buf[HEADER_SIZE];
|
||||
ImFileType *type;
|
||||
const ImFileType *type;
|
||||
BLI_stat_t st;
|
||||
int fp;
|
||||
|
||||
|
@ -442,7 +442,7 @@ bool IMB_isanim(const char *filename)
|
|||
|
||||
bool IMB_isfloat(ImBuf *ibuf)
|
||||
{
|
||||
ImFileType *type;
|
||||
const ImFileType *type;
|
||||
|
||||
for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
|
||||
if (type->ftype(type, ibuf)) {
|
||||
|
|
|
@ -41,14 +41,14 @@
|
|||
#include "IMB_colormanagement.h"
|
||||
#include "IMB_colormanagement_intern.h"
|
||||
|
||||
static ImBuf *prepare_write_imbuf(ImFileType *type, ImBuf *ibuf)
|
||||
static ImBuf *prepare_write_imbuf(const ImFileType *type, ImBuf *ibuf)
|
||||
{
|
||||
return IMB_prepare_write_ImBuf((type->flag & IM_FTYPE_FLOAT), ibuf);
|
||||
}
|
||||
|
||||
short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags)
|
||||
{
|
||||
ImFileType *type;
|
||||
const ImFileType *type;
|
||||
|
||||
if (ibuf == NULL) return (false);
|
||||
ibuf->flags = flags;
|
||||
|
|
Loading…
Reference in New Issue