30 uint32_t *rect = (uint32_t *)thumb->data.data();
31 int x = thumb->width,
y = thumb->height;
33 uint32_t *bottom =
top + ((
y - 1) *
x);
34 uint32_t *line = (uint32_t *)malloc(
x *
sizeof(uint32_t));
38 memcpy(line,
top,
x *
sizeof(uint32_t));
39 memcpy(
top, bottom,
x *
sizeof(uint32_t));
40 memcpy(bottom, line,
x *
sizeof(uint32_t));
50 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) {
92 if (!bhead.has_value()) {
100 switch (bhead->code) {
101 case MAKE_ID(
'T',
'E',
'S',
'T'): {
103 if (!
file_read(file, shape,
sizeof(shape))) {
110 size_t data_size = bhead->len -
sizeof(shape);
112 if (thumb->
width < 0 || thumb->
height < 0 || data_size != expected_size) {
122 case MAKE_ID(
'R',
'E',
'N',
'D'): {
142 char magic_bytes[12];
143 if (rawfile->
read(rawfile, magic_bytes,
sizeof(magic_bytes)) !=
sizeof(magic_bytes)) {
144 rawfile->
close(rawfile);
149 rawfile->
seek(rawfile, 0, SEEK_SET);
159 if (file !=
nullptr) {
165 if (file !=
nullptr) {
171 if (rawfile !=
nullptr) {
172 rawfile->
close(rawfile);
175 if (file ==
nullptr) {
180 if (!std::holds_alternative<BlenderHeader>(header_variant)) {
184 const BlenderHeader &header = std::get<BlenderHeader>(header_variant);
#define BLI_STATIC_ASSERT(a, msg)
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)
#define MAKE_ID(a, b, c, d)
BMesh const char void * data
unsigned long long int uint64_t
blender::Array< uint8_t > data