Listing the "Blender Foundation" as copyright holder implied the Blender Foundation holds copyright to files which may include work from many developers. While keeping copyright on headers makes sense for isolated libraries, Blender's own code may be refactored or moved between files in a way that makes the per file copyright holders less meaningful. Copyright references to the "Blender Foundation" have been replaced with "Blender Authors", with the exception of `./extern/` since these this contains libraries which are more isolated, any changed to license headers there can be handled on a case-by-case basis. Some directories in `./intern/` have also been excluded: - `./intern/cycles/` it's own `AUTHORS` file is planned. - `./intern/opensubdiv/`. An "AUTHORS" file has been added, using the chromium projects authors file as a template. Design task: #110784 Ref !110783.
49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup imbuf
|
|
*/
|
|
|
|
#include "BLI_fileops.h"
|
|
#include "BLI_hash_md5.h"
|
|
#include "BLI_utildefines.h"
|
|
|
|
#include "IMB_imbuf.h"
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
#include "IMB_thumbs.h" /* own include. */
|
|
|
|
/* XXX, bad level call */
|
|
#include "../../blenfont/BLF_api.h"
|
|
|
|
/* Only change if we need to update the previews in the on-disk cache. */
|
|
#define FONT_THUMB_VERSION "1.0.1"
|
|
|
|
ImBuf *IMB_thumb_load_font(const char *filename, uint x, uint y)
|
|
{
|
|
ImBuf *ibuf = IMB_allocImBuf(x, y, 32, IB_rect | IB_metadata);
|
|
|
|
/* fill with white and zero alpha */
|
|
const float col[4] = {1.0f, 1.0f, 1.0f, 0.0f};
|
|
IMB_rectfill(ibuf, col);
|
|
|
|
if (!BLF_thumb_preview(filename, ibuf->byte_buffer.data, ibuf->x, ibuf->y, ibuf->channels)) {
|
|
IMB_freeImBuf(ibuf);
|
|
ibuf = nullptr;
|
|
}
|
|
|
|
return ibuf;
|
|
}
|
|
|
|
bool IMB_thumb_load_font_get_hash(char *r_hash)
|
|
{
|
|
uchar digest[16];
|
|
BLI_hash_md5_buffer(FONT_THUMB_VERSION, sizeof(FONT_THUMB_VERSION), digest);
|
|
r_hash[0] = '\0';
|
|
BLI_hash_md5_to_hexdigest(digest, r_hash);
|
|
|
|
return true;
|
|
}
|