From 008863daec1249d1f17bc69e1105e336db690d63 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 7 May 2010 15:18:04 +0000 Subject: Merge image related changes from the render branch. This includes the image tile cache code in imbuf, but it is not hooked up to the render engine. Imbuf module: some small refactoring and removing a lot of unused or old code (about 6.5k lines). * Added a ImFileType struct with callbacks to make adding an file format type, or making changes to the API easier. * Move imbuf init/exit code into IMB_init()/IMB_exit() functions. * Increased mipmap levels from 10 to 20, you run into this limit already with a 2k image. * Removed hamx, amiga, anim5 format support. * Removed colormap saving, only simple colormap code now for reading tga. * Removed gen_dynlibtiff.py, editing this is almost as much work as just editing the code directly. * Functions removed that were only used for sequencer plugin API: IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp, IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace, IMB_dit0, IMB_dit2, IMB_cspace * Write metadata info into OpenEXR images. Can be viewed with the command line utility 'exrheader' For the image tile cache code, see this page: http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache --- source/blender/imbuf/intern/metadata.c | 159 +++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 source/blender/imbuf/intern/metadata.c (limited to 'source/blender/imbuf/intern/metadata.c') diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.c new file mode 100644 index 00000000000..66fe1089aea --- /dev/null +++ b/source/blender/imbuf/intern/metadata.c @@ -0,0 +1,159 @@ +/** + * $Id: metadata.c 28209 2010-04-15 15:49:48Z blendix $ + * + * ***** BEGIN GPL 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. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Austin Benesh. Ton Roosendaal. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include + +#include "BLI_blenlib.h" +#include "MEM_guardedalloc.h" + +#include "IMB_imbuf_types.h" +#include "IMB_imbuf.h" + +#include "IMB_metadata.h" + + + +void IMB_metadata_free(struct ImBuf* img) +{ + ImMetaData *info; + + if (!img) + return; + if (!img->metadata) { + return; + } + info = img->metadata; + while (info) { + ImMetaData* next = info->next; + MEM_freeN(info->key); + MEM_freeN(info->value); + MEM_freeN(info); + info = next; + } +} + +int IMB_metadata_get_field(struct ImBuf* img, const char* key, char* field, int len) +{ + ImMetaData *info; + int retval = 0; + + if (!img) + return 0; + if (!img->metadata) { + return 0; + } + info = img->metadata; + while (info) { + if (strcmp(key, info->key) == 0) { + BLI_strncpy(field, info->value, len); + retval = 1; + break; + } + info = info->next; + } + return retval; +} + +int IMB_metadata_add_field(struct ImBuf* img, const char* key, const char* field) +{ + ImMetaData *info; + ImMetaData *last; + + if (!img) + return 0; + + if (!img->metadata) { + img->metadata = MEM_callocN(sizeof(ImMetaData), "ImMetaData"); + info = img->metadata; + } else { + info = img->metadata; + last = info; + while (info) { + last = info; + info = info->next; + } + info = MEM_callocN(sizeof(ImMetaData), "ImMetaData"); + last->next = info; + } + info->key = BLI_strdup(key); + info->value = BLI_strdup(field); + return 1; +} + +int IMB_metadata_del_field(struct ImBuf *img, const char *key) +{ + ImMetaData *p, *p1; + + if ((!img) || (!img->metadata)) + return (0); + + p = img->metadata; + p1 = NULL; + while (p) { + if (!strcmp (key, p->key)) { + if (p1) + p1->next = p->next; + else + img->metadata = p->next; + + MEM_freeN(p->key); + MEM_freeN(p->value); + MEM_freeN(p); + return (1); + } + p1 = p; + p = p->next; + } + return (0); +} + +int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field) +{ + ImMetaData *p; + + if (!img) + return (0); + + if (!img->metadata) + return (IMB_metadata_add_field (img, key, field)); + + p = img->metadata; + while (p) { + if (!strcmp (key, p->key)) { + MEM_freeN (p->value); + p->value = BLI_strdup (field); + return (1); + } + p = p->next; + } + + return (IMB_metadata_add_field (img, key, field)); +} + -- cgit v1.2.3