Welcome to mirror list, hosted at ThFree Co, Russian Federation.

thumbs_font.c « intern « imbuf « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0f18e9dd4cb3135a2cf6865241830e42e09500bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* 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.0"

struct ImBuf *IMB_thumb_load_font(const char *filename, unsigned int x, unsigned int y)
{
  struct 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, (unsigned char *)ibuf->rect, ibuf->x, ibuf->y, ibuf->channels)) {
    IMB_freeImBuf(ibuf);
    ibuf = NULL;
  }

  return ibuf;
}

bool IMB_thumb_load_font_get_hash(char *r_hash)
{
  unsigned char 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;
}