29 uint32_t *rect = (uint32_t *)thumb->
data.
data();
32 uint32_t *bottom = top + ((
y - 1) *
x);
33 uint32_t *line = (uint32_t *)malloc(
x *
sizeof(uint32_t));
37 memcpy(line, top,
x *
sizeof(uint32_t));
38 memcpy(top, bottom,
x *
sizeof(uint32_t));
39 memcpy(bottom, line,
x *
sizeof(uint32_t));
49 memcpy(&
data, bytes, 4);
58 return (file->
read(file, buf, buf_len) == buf_len);
63 if (file->
seek !=
nullptr) {
64 if (file->
seek(file,
len, SEEK_CUR) == -1) {
71 constexpr size_t dummy_data_size = 4096;
74 const size_t len_chunk = std::min(
len, dummy_data_size);
75 if (
size_t(file->
read(file, dummy_data.
data(), len_chunk)) != len_chunk) {
93 if (!bhead.has_value()) {
101 switch (bhead->code) {
102 case MAKE_ID(
'T',
'E',
'S',
'T'): {
104 if (bhead->len <
int64_t(
sizeof(shape)) || !
file_read(file, shape,
sizeof(shape))) {
113 constexpr int max_size = 4096;
114 const size_t data_size = size_t(bhead->len) -
sizeof(shape);
117 thumb->
height > max_size || data_size != expected_size)
128 case MAKE_ID(
'R',
'E',
'N',
'D'): {
148 char magic_bytes[12];
149 if (rawfile->
read(rawfile, magic_bytes,
sizeof(magic_bytes)) !=
sizeof(magic_bytes)) {
150 rawfile->
close(rawfile);
155 rawfile->
seek(rawfile, 0, SEEK_SET);
165 if (file !=
nullptr) {
171 if (file !=
nullptr) {
177 if (rawfile !=
nullptr) {
178 rawfile->
close(rawfile);
181 if (file ==
nullptr) {
186 if (!std::holds_alternative<BlenderHeader>(header_variant)) {
190 const BlenderHeader &header = std::get<BlenderHeader>(header_variant);
BLI_INLINE void BLI_endian_switch_int32(int *val) ATTR_NONNULL(1)
File and directory operations.
bool BLI_file_magic_is_gzip(const char header[4])
bool BLI_file_magic_is_zstd(const char header[4])
Wrapper for reading from various sources (e.g. raw files, compressed files, memory....
FileReader * BLI_filereader_new_zstd(FileReader *base) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
FileReader * BLI_filereader_new_gzip(FileReader *base) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_kdtree_nd_ free(KDTree *tree)
int bool BLI_str_startswith(const char *__restrict str, const char *__restrict start) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
std::optional< BHead > BLO_readfile_read_bhead(FileReader *file, BHeadType type, bool do_endian_swap)
eThumbStatus blendthumb_create_thumb_from_file(FileReader *rawfile, Thumbnail *thumb)
#define MAKE_ID(a, b, c, d)
BMesh const char void * data
unsigned long long int uint64_t
ccl_device_inline float len(const float2 a)
blender::Array< uint8_t > data