2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2007-09-02 17:25:03 +00:00
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-09-02 17:25:03 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2007 Blender Foundation
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Andrea Weikert.
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:23:21 +00:00
|
|
|
/** \file blender/imbuf/intern/thumbs.c
|
|
|
|
|
* \ingroup imbuf
|
|
|
|
|
*/
|
|
|
|
|
|
2007-12-24 18:53:37 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2013-03-04 18:36:37 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2012-08-12 23:28:33 +00:00
|
|
|
#include "BLI_string.h"
|
|
|
|
|
#include "BLI_path_util.h"
|
|
|
|
|
#include "BLI_fileops.h"
|
2011-12-21 13:48:51 +00:00
|
|
|
#include "BLI_md5.h"
|
2014-04-02 11:43:54 +02:00
|
|
|
#include "BLI_system.h"
|
|
|
|
|
#include BLI_SYSTEM_PID_H
|
2011-12-21 13:48:51 +00:00
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
#include "IMB_thumbs.h"
|
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
2010-05-07 15:18:04 +00:00
|
|
|
#include "IMB_metadata.h"
|
2007-09-02 17:25:03 +00:00
|
|
|
|
2009-09-06 13:20:05 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
#ifdef WIN32
|
2012-04-15 07:54:07 +00:00
|
|
|
# include <windows.h> /* need to include windows.h so _WIN32_IE is defined */
|
|
|
|
|
# ifndef _WIN32_IE
|
|
|
|
|
# define _WIN32_IE 0x0400 /* minimal requirements for SHGetSpecialFolderPath on MINGW MSVC has this defined already */
|
|
|
|
|
# endif
|
|
|
|
|
# include <shlobj.h> /* for SHGetSpecialFolderPath, has to be done before BLI_winstuff
|
|
|
|
|
* because 'near' is disabled through BLI_windstuff */
|
|
|
|
|
# include <direct.h> /* chdir */
|
|
|
|
|
# include "BLI_winstuff.h"
|
|
|
|
|
# include "utfconv.h"
|
2007-09-02 17:25:03 +00:00
|
|
|
#endif
|
|
|
|
|
|
2014-04-07 08:42:08 +10:00
|
|
|
#if defined(WIN32) || defined(__APPLE__)
|
|
|
|
|
/* pass */
|
|
|
|
|
#else
|
|
|
|
|
# define USE_FREEDESKTOP
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* '$HOME/.cache/thumbnails' or '$HOME/.thumbnails' */
|
|
|
|
|
#ifdef USE_FREEDESKTOP
|
|
|
|
|
# define THUMBNAILS "thumbnails"
|
|
|
|
|
#else
|
|
|
|
|
# define THUMBNAILS ".thumbnails"
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-07-27 09:26:22 +00:00
|
|
|
#define URI_MAX (FILE_MAX * 3 + 8)
|
2007-09-02 17:25:03 +00:00
|
|
|
|
2014-04-07 08:42:08 +10:00
|
|
|
static bool get_thumb_dir(char *dir, ThumbSize size)
|
2007-09-02 17:25:03 +00:00
|
|
|
{
|
2013-07-23 12:49:30 +00:00
|
|
|
char *s = dir;
|
2013-07-23 16:04:49 +00:00
|
|
|
const char *subdir;
|
2007-09-02 17:25:03 +00:00
|
|
|
#ifdef WIN32
|
2012-05-16 09:26:37 +00:00
|
|
|
wchar_t dir_16[MAX_PATH];
|
2007-09-02 17:25:03 +00:00
|
|
|
/* yes, applications shouldn't store data there, but so does GIMP :)*/
|
2012-03-20 02:17:37 +00:00
|
|
|
SHGetSpecialFolderPathW(0, dir_16, CSIDL_PROFILE, 0);
|
2012-04-29 15:47:02 +00:00
|
|
|
conv_utf_16_to_8(dir_16, dir, FILE_MAX);
|
2013-07-23 12:49:30 +00:00
|
|
|
s += strlen(dir);
|
2014-04-07 04:18:03 +03:00
|
|
|
#else
|
|
|
|
|
#if defined(USE_FREEDESKTOP)
|
2014-04-07 08:42:08 +10:00
|
|
|
const char *home_cache = getenv("XDG_CACHE_HOME");
|
|
|
|
|
const char *home = home_cache ? home_cache : getenv("HOME");
|
2007-09-02 17:25:03 +00:00
|
|
|
#else
|
2012-05-16 09:26:37 +00:00
|
|
|
const char *home = getenv("HOME");
|
2014-04-07 08:42:08 +10:00
|
|
|
#endif
|
2007-09-02 17:25:03 +00:00
|
|
|
if (!home) return 0;
|
2013-07-23 12:49:30 +00:00
|
|
|
s += BLI_strncpy_rlen(s, home, FILE_MAX);
|
2014-04-07 08:42:08 +10:00
|
|
|
|
|
|
|
|
#ifdef USE_FREEDESKTOP
|
|
|
|
|
if (!home_cache) {
|
|
|
|
|
s += BLI_strncpy_rlen(s, "/.cache", FILE_MAX - (s - dir));
|
|
|
|
|
}
|
2007-09-02 17:25:03 +00:00
|
|
|
#endif
|
2014-04-07 04:18:03 +03:00
|
|
|
#endif
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (size) {
|
2007-09-02 17:25:03 +00:00
|
|
|
case THB_NORMAL:
|
2014-04-07 08:42:08 +10:00
|
|
|
subdir = "/" THUMBNAILS "/normal/";
|
2007-09-02 17:25:03 +00:00
|
|
|
break;
|
|
|
|
|
case THB_LARGE:
|
2014-04-07 08:42:08 +10:00
|
|
|
subdir = "/" THUMBNAILS "/large/";
|
2007-09-02 17:25:03 +00:00
|
|
|
break;
|
|
|
|
|
case THB_FAIL:
|
2014-04-07 08:42:08 +10:00
|
|
|
subdir = "/" THUMBNAILS "/fail/blender/";
|
2007-09-02 17:25:03 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return 0; /* unknown size */
|
|
|
|
|
}
|
2013-07-23 12:49:30 +00:00
|
|
|
|
|
|
|
|
s += BLI_strncpy_rlen(s, subdir, FILE_MAX - (s - dir));
|
|
|
|
|
(void)s;
|
|
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-07 08:42:08 +10:00
|
|
|
#undef THUMBNAILS
|
|
|
|
|
|
|
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
/** ----- begin of adapted code from glib ---
|
|
|
|
|
* The following code is adapted from function g_escape_uri_string from the gnome glib
|
|
|
|
|
* Source: http://svn.gnome.org/viewcvs/glib/trunk/glib/gconvert.c?view=markup
|
|
|
|
|
* released under the Gnu General Public License.
|
|
|
|
|
*/
|
|
|
|
|
typedef enum {
|
2012-05-16 09:26:37 +00:00
|
|
|
UNSAFE_ALL = 0x1, /* Escape all unsafe characters */
|
|
|
|
|
UNSAFE_ALLOW_PLUS = 0x2, /* Allows '+' */
|
|
|
|
|
UNSAFE_PATH = 0x8, /* Allows '/', '&', '=', ':', '@', '+', '$' and ',' */
|
|
|
|
|
UNSAFE_HOST = 0x10, /* Allows '/' and ':' and '@' */
|
|
|
|
|
UNSAFE_SLASHES = 0x20 /* Allows all characters except for '/' and '%' */
|
2007-09-02 17:25:03 +00:00
|
|
|
} UnsafeCharacterSet;
|
|
|
|
|
|
|
|
|
|
static const unsigned char acceptable[96] = {
|
2011-04-21 15:53:30 +00:00
|
|
|
/* A table of the ASCII chars from space (32) to DEL (127) */
|
|
|
|
|
/* ! " # $ % & ' ( ) * + , - . / */
|
|
|
|
|
0x00,0x3F,0x20,0x20,0x28,0x00,0x2C,0x3F,0x3F,0x3F,0x3F,0x2A,0x28,0x3F,0x3F,0x1C,
|
|
|
|
|
/* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
|
|
|
|
|
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x38,0x20,0x20,0x2C,0x20,0x20,
|
|
|
|
|
/* @ A B C D E F G H I J K L M N O */
|
|
|
|
|
0x38,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
|
|
|
|
/* P Q R S T U V W X Y Z [ \ ] ^ _ */
|
|
|
|
|
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x20,0x3F,
|
|
|
|
|
/* ` a b c d e f g h i j k l m n o */
|
|
|
|
|
0x20,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
|
|
|
|
|
/* p q r s t u v w x y z { | } ~ DEL */
|
|
|
|
|
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x3F,0x20
|
2007-09-02 17:25:03 +00:00
|
|
|
};
|
|
|
|
|
|
2007-09-17 10:26:09 +00:00
|
|
|
static const char hex[17] = "0123456789abcdef";
|
2007-09-02 17:25:03 +00:00
|
|
|
|
|
|
|
|
/* Note: This escape function works on file: URIs, but if you want to
|
|
|
|
|
* escape something else, please read RFC-2396 */
|
2014-04-30 20:43:50 +10:00
|
|
|
static void escape_uri_string(const char *string, char *escaped_string, int escaped_string_size, UnsafeCharacterSet mask)
|
2007-09-02 17:25:03 +00:00
|
|
|
{
|
2012-05-16 09:26:37 +00:00
|
|
|
#define ACCEPTABLE(a) ((a) >= 32 && (a) < 128 && (acceptable[(a) - 32] & use_mask))
|
2007-09-02 17:25:03 +00:00
|
|
|
|
|
|
|
|
const char *p;
|
|
|
|
|
char *q;
|
|
|
|
|
int c;
|
|
|
|
|
UnsafeCharacterSet use_mask;
|
|
|
|
|
use_mask = mask;
|
|
|
|
|
|
2014-04-30 20:43:50 +10:00
|
|
|
BLI_assert(escaped_string_size > 0);
|
|
|
|
|
|
|
|
|
|
/* space for \0 */
|
|
|
|
|
escaped_string_size -= 1;
|
|
|
|
|
|
|
|
|
|
for (q = escaped_string, p = string; (*p != '\0') && escaped_string_size; p++) {
|
2007-09-02 17:25:03 +00:00
|
|
|
c = (unsigned char) *p;
|
|
|
|
|
|
2012-05-16 09:26:37 +00:00
|
|
|
if (!ACCEPTABLE(c)) {
|
2014-04-30 20:43:50 +10:00
|
|
|
if (escaped_string_size < 3) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
*q++ = '%'; /* means hex coming */
|
|
|
|
|
*q++ = hex[c >> 4];
|
|
|
|
|
*q++ = hex[c & 15];
|
2014-04-30 20:43:50 +10:00
|
|
|
escaped_string_size -= 3;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2007-09-02 17:25:03 +00:00
|
|
|
*q++ = *p;
|
2014-04-30 20:43:50 +10:00
|
|
|
escaped_string_size -= 1;
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
2013-02-04 00:18:09 +00:00
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
*q = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-16 09:26:37 +00:00
|
|
|
static void to_hex_char(char *hexbytes, const unsigned char *bytes, int len)
|
2007-09-02 17:25:03 +00:00
|
|
|
{
|
|
|
|
|
const unsigned char *p;
|
|
|
|
|
char *q;
|
|
|
|
|
|
|
|
|
|
for (q = hexbytes, p = bytes; len; p++) {
|
|
|
|
|
const unsigned char c = (unsigned char) *p;
|
|
|
|
|
len--;
|
|
|
|
|
*q++ = hex[c >> 4];
|
|
|
|
|
*q++ = hex[c & 15];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** ----- end of adapted code from glib --- */
|
|
|
|
|
|
2012-03-11 19:09:01 +00:00
|
|
|
static int uri_from_filename(const char *path, char *uri)
|
2007-09-02 17:25:03 +00:00
|
|
|
{
|
2012-10-21 05:46:41 +00:00
|
|
|
char orig_uri[URI_MAX];
|
2012-05-16 09:26:37 +00:00
|
|
|
const char *dirstart = path;
|
2007-09-02 17:25:03 +00:00
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
{
|
|
|
|
|
char vol[3];
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(orig_uri, "file:///", FILE_MAX);
|
2010-03-10 19:30:20 +00:00
|
|
|
if (strlen(path) < 2 && path[1] != ':') {
|
2007-09-02 17:25:03 +00:00
|
|
|
/* not a correct absolute path */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
/* on windows, using always uppercase drive/volume letter in uri */
|
2010-03-10 19:30:20 +00:00
|
|
|
vol[0] = (unsigned char)toupper(path[0]);
|
2007-09-02 17:25:03 +00:00
|
|
|
vol[1] = ':';
|
|
|
|
|
vol[2] = '\0';
|
|
|
|
|
strcat(orig_uri, vol);
|
|
|
|
|
dirstart += 2;
|
|
|
|
|
}
|
|
|
|
|
strcat(orig_uri, dirstart);
|
|
|
|
|
BLI_char_switch(orig_uri, '\\', '/');
|
2013-07-27 09:26:22 +00:00
|
|
|
#else
|
|
|
|
|
BLI_snprintf(orig_uri, URI_MAX, "file://%s", dirstart);
|
|
|
|
|
#endif
|
2007-09-02 17:25:03 +00:00
|
|
|
|
|
|
|
|
#ifdef WITH_ICONV
|
|
|
|
|
{
|
2013-07-27 09:26:22 +00:00
|
|
|
char uri_utf8[URI_MAX];
|
|
|
|
|
escape_uri_string(orig_uri, uri_utf8, URI_MAX, UNSAFE_PATH);
|
2007-09-02 17:25:03 +00:00
|
|
|
BLI_string_to_utf8(uri_utf8, uri, NULL);
|
|
|
|
|
}
|
|
|
|
|
#else
|
2013-07-27 09:26:22 +00:00
|
|
|
escape_uri_string(orig_uri, uri, URI_MAX, UNSAFE_PATH);
|
2007-09-02 17:25:03 +00:00
|
|
|
#endif
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-16 09:26:37 +00:00
|
|
|
static void thumbname_from_uri(const char *uri, char *thumb, const int thumb_len)
|
2007-09-02 17:25:03 +00:00
|
|
|
{
|
|
|
|
|
char hexdigest[33];
|
|
|
|
|
unsigned char digest[16];
|
|
|
|
|
|
2012-04-29 17:11:40 +00:00
|
|
|
md5_buffer(uri, strlen(uri), digest);
|
2007-09-02 17:25:03 +00:00
|
|
|
hexdigest[0] = '\0';
|
|
|
|
|
to_hex_char(hexdigest, digest, 16);
|
|
|
|
|
hexdigest[32] = '\0';
|
2011-02-12 16:54:24 +00:00
|
|
|
BLI_snprintf(thumb, thumb_len, "%s.png", hexdigest);
|
2012-04-16 15:13:21 +00:00
|
|
|
|
|
|
|
|
// printf("%s: '%s' --> '%s'\n", __func__, uri, thumb);
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
2012-05-16 09:26:37 +00:00
|
|
|
static int thumbpath_from_uri(const char *uri, char *path, const int path_len, ThumbSize size)
|
2007-09-02 17:25:03 +00:00
|
|
|
{
|
|
|
|
|
char tmppath[FILE_MAX];
|
|
|
|
|
int rv = 0;
|
|
|
|
|
|
|
|
|
|
if (get_thumb_dir(tmppath, size)) {
|
|
|
|
|
char thumb[40];
|
2011-02-12 16:54:24 +00:00
|
|
|
thumbname_from_uri(uri, thumb, sizeof(thumb));
|
|
|
|
|
BLI_snprintf(path, path_len, "%s%s", tmppath, thumb);
|
2007-09-02 17:25:03 +00:00
|
|
|
rv = 1;
|
|
|
|
|
}
|
|
|
|
|
return rv;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-13 15:02:21 +00:00
|
|
|
void IMB_thumb_makedirs(void)
|
2009-03-03 10:24:06 +00:00
|
|
|
{
|
|
|
|
|
char tpath[FILE_MAX];
|
|
|
|
|
if (get_thumb_dir(tpath, THB_NORMAL)) {
|
2011-10-22 15:35:49 +00:00
|
|
|
BLI_dir_create_recursive(tpath);
|
2009-03-03 10:24:06 +00:00
|
|
|
}
|
|
|
|
|
if (get_thumb_dir(tpath, THB_FAIL)) {
|
2011-10-22 15:35:49 +00:00
|
|
|
BLI_dir_create_recursive(tpath);
|
2009-03-03 10:24:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-09-02 17:25:03 +00:00
|
|
|
|
|
|
|
|
/* create thumbnail for file and returns new imbuf for thumbnail */
|
2012-05-16 09:26:37 +00:00
|
|
|
ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, ImBuf *img)
|
2007-09-02 17:25:03 +00:00
|
|
|
{
|
2012-05-16 09:26:37 +00:00
|
|
|
char uri[URI_MAX] = "";
|
|
|
|
|
char desc[URI_MAX + 22];
|
2007-09-02 17:25:03 +00:00
|
|
|
char tpath[FILE_MAX];
|
|
|
|
|
char tdir[FILE_MAX];
|
|
|
|
|
char temp[FILE_MAX];
|
2012-05-16 09:26:37 +00:00
|
|
|
char mtime[40] = "0"; /* in case we can't stat the file */
|
|
|
|
|
char cwidth[40] = "0"; /* in case images have no data */
|
|
|
|
|
char cheight[40] = "0";
|
2007-09-02 17:25:03 +00:00
|
|
|
char thumb[40];
|
|
|
|
|
short tsize = 128;
|
|
|
|
|
short ex, ey;
|
2012-10-21 05:46:41 +00:00
|
|
|
float scaledx, scaledy;
|
2007-09-02 17:25:03 +00:00
|
|
|
struct stat info;
|
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (size) {
|
2007-09-02 17:25:03 +00:00
|
|
|
case THB_NORMAL:
|
|
|
|
|
tsize = 128;
|
|
|
|
|
break;
|
|
|
|
|
case THB_LARGE:
|
|
|
|
|
tsize = 256;
|
|
|
|
|
break;
|
|
|
|
|
case THB_FAIL:
|
2010-08-12 15:15:02 +00:00
|
|
|
tsize = 1;
|
2007-09-02 17:25:03 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
2011-03-05 10:29:10 +00:00
|
|
|
return NULL; /* unknown size */
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-02 10:22:49 +00:00
|
|
|
/* exception, skip images over 100mb */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (source == THB_SOURCE_IMAGE) {
|
2013-04-05 00:10:33 +00:00
|
|
|
const size_t file_size = BLI_file_size(path);
|
|
|
|
|
if (file_size != -1 && file_size > THUMB_SIZE_MAX) {
|
2011-05-02 10:22:49 +00:00
|
|
|
// printf("file too big: %d, skipping %s\n", (int)size, path);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-10 19:30:20 +00:00
|
|
|
uri_from_filename(path, uri);
|
2011-02-12 16:54:24 +00:00
|
|
|
thumbname_from_uri(uri, thumb, sizeof(thumb));
|
2007-09-02 17:25:03 +00:00
|
|
|
if (get_thumb_dir(tdir, size)) {
|
|
|
|
|
BLI_snprintf(tpath, FILE_MAX, "%s%s", tdir, thumb);
|
|
|
|
|
thumb[8] = '\0'; /* shorten for tempname, not needed anymore */
|
|
|
|
|
BLI_snprintf(temp, FILE_MAX, "%sblender_%d_%s.png", tdir, abs(getpid()), thumb);
|
2011-04-06 06:03:48 +00:00
|
|
|
if (BLI_path_ncmp(path, tdir, sizeof(tdir)) == 0) {
|
2007-09-02 17:25:03 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
if (size == THB_FAIL) {
|
2012-04-29 15:47:02 +00:00
|
|
|
img = IMB_allocImBuf(1, 1, 32, IB_rect | IB_metadata);
|
2011-03-05 10:29:10 +00:00
|
|
|
if (!img) return NULL;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-05-24 21:52:18 +00:00
|
|
|
if (THB_SOURCE_IMAGE == source || THB_SOURCE_BLEND == source) {
|
|
|
|
|
|
|
|
|
|
/* only load if we didnt give an image */
|
2012-05-16 09:26:37 +00:00
|
|
|
if (img == NULL) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (THB_SOURCE_BLEND == source) {
|
2010-05-24 21:52:18 +00:00
|
|
|
img = IMB_loadblend_thumb(path);
|
|
|
|
|
}
|
|
|
|
|
else {
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
img = IMB_loadiffname(path, IB_rect | IB_metadata, NULL);
|
2010-05-24 21:52:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-02 17:41:25 +00:00
|
|
|
if (img != NULL) {
|
2013-06-25 14:48:30 +00:00
|
|
|
BLI_stat(path, &info);
|
2011-12-04 15:45:53 +00:00
|
|
|
BLI_snprintf(mtime, sizeof(mtime), "%ld", (long int)info.st_mtime);
|
2011-02-12 16:54:24 +00:00
|
|
|
BLI_snprintf(cwidth, sizeof(cwidth), "%d", img->x);
|
|
|
|
|
BLI_snprintf(cheight, sizeof(cheight), "%d", img->y);
|
2007-09-02 17:41:25 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else if (THB_SOURCE_MOVIE == source) {
|
2012-05-16 09:26:37 +00:00
|
|
|
struct anim *anim = NULL;
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
anim = IMB_open_anim(path, IB_rect | IB_metadata, 0, NULL);
|
2007-09-02 17:25:03 +00:00
|
|
|
if (anim != NULL) {
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
img = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
|
2007-09-02 17:25:03 +00:00
|
|
|
if (img == NULL) {
|
2010-03-10 19:30:20 +00:00
|
|
|
printf("not an anim; %s\n", path);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2007-09-02 17:25:03 +00:00
|
|
|
IMB_freeImBuf(img);
|
2012-10-21 05:46:41 +00:00
|
|
|
img = IMB_anim_previewframe(anim);
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
IMB_free_anim(anim);
|
|
|
|
|
}
|
2013-06-25 14:48:30 +00:00
|
|
|
BLI_stat(path, &info);
|
2011-12-04 15:45:53 +00:00
|
|
|
BLI_snprintf(mtime, sizeof(mtime), "%ld", (long int)info.st_mtime);
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
2011-03-05 10:29:10 +00:00
|
|
|
if (!img) return NULL;
|
2007-09-02 17:25:03 +00:00
|
|
|
|
|
|
|
|
if (img->x > img->y) {
|
|
|
|
|
scaledx = (float)tsize;
|
2012-05-16 09:26:37 +00:00
|
|
|
scaledy = ( (float)img->y / (float)img->x) * tsize;
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
scaledy = (float)tsize;
|
2012-05-16 09:26:37 +00:00
|
|
|
scaledx = ( (float)img->x / (float)img->y) * tsize;
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
ex = (short)scaledx;
|
|
|
|
|
ey = (short)scaledy;
|
|
|
|
|
|
2011-04-08 03:56:15 +00:00
|
|
|
/* save some time by only scaling byte buf */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (img->rect_float) {
|
|
|
|
|
if (img->rect == NULL) {
|
2011-04-08 03:56:15 +00:00
|
|
|
IMB_rect_from_float(img);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
imb_freerectfloatImBuf(img);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
IMB_scaleImBuf(img, ex, ey);
|
|
|
|
|
}
|
2011-02-12 16:54:24 +00:00
|
|
|
BLI_snprintf(desc, sizeof(desc), "Thumbnail for %s", uri);
|
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
2010-05-07 15:18:04 +00:00
|
|
|
IMB_metadata_change_field(img, "Description", desc);
|
|
|
|
|
IMB_metadata_change_field(img, "Software", "Blender");
|
|
|
|
|
IMB_metadata_change_field(img, "Thumb::URI", uri);
|
|
|
|
|
IMB_metadata_change_field(img, "Thumb::MTime", mtime);
|
2007-09-02 17:25:03 +00:00
|
|
|
if (THB_SOURCE_IMAGE == source) {
|
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
2010-05-07 15:18:04 +00:00
|
|
|
IMB_metadata_change_field(img, "Thumb::Image::Width", cwidth);
|
|
|
|
|
IMB_metadata_change_field(img, "Thumb::Image::Height", cheight);
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
img->ftype = PNG;
|
2011-11-21 20:47:19 +00:00
|
|
|
img->planes = 32;
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
|
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
2010-05-07 15:18:04 +00:00
|
|
|
if (IMB_saveiff(img, temp, IB_rect | IB_metadata)) {
|
2007-09-02 17:25:03 +00:00
|
|
|
#ifndef WIN32
|
|
|
|
|
chmod(temp, S_IRUSR | S_IWUSR);
|
2012-04-16 15:13:21 +00:00
|
|
|
#endif
|
|
|
|
|
// printf("%s saving thumb: '%s'\n", __func__, tpath);
|
|
|
|
|
|
2007-09-02 17:25:03 +00:00
|
|
|
BLI_rename(temp, tpath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return img;
|
|
|
|
|
}
|
|
|
|
|
return img;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* read thumbnail for file and returns new imbuf for thumbnail */
|
2012-05-16 09:26:37 +00:00
|
|
|
ImBuf *IMB_thumb_read(const char *path, ThumbSize size)
|
2007-09-02 17:25:03 +00:00
|
|
|
{
|
|
|
|
|
char thumb[FILE_MAX];
|
2013-07-27 09:26:22 +00:00
|
|
|
char uri[URI_MAX];
|
2011-03-05 10:29:10 +00:00
|
|
|
ImBuf *img = NULL;
|
2007-09-02 17:25:03 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
if (!uri_from_filename(path, uri)) {
|
2007-09-02 17:25:03 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
img = IMB_loadiffname(thumb, IB_rect | IB_metadata, NULL);
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return img;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* delete all thumbs for the file */
|
2012-05-16 09:26:37 +00:00
|
|
|
void IMB_thumb_delete(const char *path, ThumbSize size)
|
2007-09-02 17:25:03 +00:00
|
|
|
{
|
|
|
|
|
char thumb[FILE_MAX];
|
2013-07-27 09:26:22 +00:00
|
|
|
char uri[URI_MAX];
|
2007-09-02 17:25:03 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
if (!uri_from_filename(path, uri)) {
|
2007-09-02 17:25:03 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2011-02-12 16:54:24 +00:00
|
|
|
if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
|
2011-04-06 06:03:48 +00:00
|
|
|
if (BLI_path_ncmp(path, thumb, sizeof(thumb)) == 0) {
|
2007-09-02 17:25:03 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (BLI_exists(thumb)) {
|
2013-03-05 03:53:22 +00:00
|
|
|
BLI_delete(thumb, false, false);
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* create the thumb if necessary and manage failed and old thumbs */
|
2012-05-16 09:26:37 +00:00
|
|
|
ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source)
|
2007-09-02 17:25:03 +00:00
|
|
|
{
|
|
|
|
|
char thumb[FILE_MAX];
|
2013-07-27 09:26:22 +00:00
|
|
|
char uri[URI_MAX];
|
2007-09-02 17:25:03 +00:00
|
|
|
struct stat st;
|
2012-05-16 09:26:37 +00:00
|
|
|
ImBuf *img = NULL;
|
2010-03-10 19:30:20 +00:00
|
|
|
|
2012-11-05 13:00:33 +00:00
|
|
|
if (BLI_stat(path, &st)) {
|
2007-09-02 17:25:03 +00:00
|
|
|
return NULL;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
if (!uri_from_filename(path, uri)) {
|
2007-09-02 17:25:03 +00:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2011-02-12 16:54:24 +00:00
|
|
|
if (thumbpath_from_uri(uri, thumb, sizeof(thumb), THB_FAIL)) {
|
2007-09-02 17:25:03 +00:00
|
|
|
/* failure thumb exists, don't try recreating */
|
|
|
|
|
if (BLI_exists(thumb)) {
|
2012-04-16 15:13:21 +00:00
|
|
|
/* clear out of date fail case */
|
|
|
|
|
if (BLI_file_older(thumb, path)) {
|
2013-03-05 03:53:22 +00:00
|
|
|
BLI_delete(thumb, false, false);
|
2012-04-16 15:13:21 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-12 16:54:24 +00:00
|
|
|
if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
|
2011-04-06 06:03:48 +00:00
|
|
|
if (BLI_path_ncmp(path, thumb, sizeof(thumb)) == 0) {
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
img = IMB_loadiffname(path, IB_rect, NULL);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else {
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
img = IMB_loadiffname(thumb, IB_rect | IB_metadata, NULL);
|
2007-09-02 17:25:03 +00:00
|
|
|
if (img) {
|
|
|
|
|
char mtime[40];
|
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
2010-05-07 15:18:04 +00:00
|
|
|
if (!IMB_metadata_get_field(img, "Thumb::MTime", mtime, 40)) {
|
2007-09-02 17:25:03 +00:00
|
|
|
/* illegal thumb, forget it! */
|
|
|
|
|
IMB_freeImBuf(img);
|
2011-03-05 10:29:10 +00:00
|
|
|
img = NULL;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2007-09-02 17:25:03 +00:00
|
|
|
time_t t = atol(mtime);
|
|
|
|
|
if (st.st_mtime != t) {
|
|
|
|
|
/* recreate all thumbs */
|
|
|
|
|
IMB_freeImBuf(img);
|
2011-03-05 10:29:10 +00:00
|
|
|
img = NULL;
|
2010-03-10 19:30:20 +00:00
|
|
|
IMB_thumb_delete(path, THB_NORMAL);
|
|
|
|
|
IMB_thumb_delete(path, THB_LARGE);
|
|
|
|
|
IMB_thumb_delete(path, THB_FAIL);
|
2010-05-24 21:52:18 +00:00
|
|
|
img = IMB_thumb_create(path, size, source, NULL);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!img) {
|
2007-09-02 17:25:03 +00:00
|
|
|
/* thumb creation failed, write fail thumb */
|
2010-05-24 21:52:18 +00:00
|
|
|
img = IMB_thumb_create(path, THB_FAIL, source, NULL);
|
2007-09-02 17:25:03 +00:00
|
|
|
if (img) {
|
|
|
|
|
/* we don't need failed thumb anymore */
|
|
|
|
|
IMB_freeImBuf(img);
|
2011-03-05 10:29:10 +00:00
|
|
|
img = NULL;
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-05-24 21:52:18 +00:00
|
|
|
img = IMB_thumb_create(path, size, source, NULL);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!img) {
|
2007-09-02 17:25:03 +00:00
|
|
|
/* thumb creation failed, write fail thumb */
|
2010-05-24 21:52:18 +00:00
|
|
|
img = IMB_thumb_create(path, THB_FAIL, source, NULL);
|
2007-09-02 17:25:03 +00:00
|
|
|
if (img) {
|
|
|
|
|
/* we don't need failed thumb anymore */
|
|
|
|
|
IMB_freeImBuf(img);
|
2011-03-05 10:29:10 +00:00
|
|
|
img = NULL;
|
2007-09-02 17:25:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return img;
|
|
|
|
|
}
|