Utilize decltype for slightly improved syntax
parent
7ff6144c2c
commit
632e4a20a9
|
@ -75,13 +75,12 @@ protected:
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
|
|
||||||
// We define the struct size because sizeof(Header) might return a wrong result because of structure padding.
|
// We define the struct size because sizeof(Header) might return a wrong result because of structure padding.
|
||||||
// Moreover, we must use this ugly and error prone syntax because Visual Studio neither support constexpr or sizeof(name_of_field).
|
static constexpr std::size_t header_size =
|
||||||
static const std::size_t header_size =
|
sizeof(decltype(type)) +
|
||||||
sizeof(uint16_t) + // type
|
sizeof(decltype(size)) +
|
||||||
sizeof(uint32_t) + // size
|
sizeof(decltype(reserved1)) +
|
||||||
sizeof(uint16_t) + // reserved1
|
sizeof(decltype(reserved2)) +
|
||||||
sizeof(uint16_t) + // reserved2
|
sizeof(decltype(offset));
|
||||||
sizeof(uint32_t); // offset
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DIB {
|
struct DIB {
|
||||||
|
@ -98,22 +97,21 @@ protected:
|
||||||
uint32_t nb_important_colors;
|
uint32_t nb_important_colors;
|
||||||
|
|
||||||
// We define the struct size because sizeof(DIB) might return a wrong result because of structure padding.
|
// We define the struct size because sizeof(DIB) might return a wrong result because of structure padding.
|
||||||
// Moreover, we must use this ugly and error prone syntax because Visual Studio neither support constexpr or sizeof(name_of_field).
|
static constexpr std::size_t dib_size =
|
||||||
static const std::size_t dib_size =
|
sizeof(decltype(size)) +
|
||||||
sizeof(uint32_t) + // size
|
sizeof(decltype(width)) +
|
||||||
sizeof(int32_t) + // width
|
sizeof(decltype(height)) +
|
||||||
sizeof(int32_t) + // height
|
sizeof(decltype(planes)) +
|
||||||
sizeof(uint16_t) + // planes
|
sizeof(decltype(bits_per_pixel)) +
|
||||||
sizeof(uint16_t) + // bits_per_pixel
|
sizeof(decltype(compression)) +
|
||||||
sizeof(uint32_t) + // compression
|
sizeof(decltype(image_size)) +
|
||||||
sizeof(uint32_t) + // image_size
|
sizeof(decltype(x_resolution)) +
|
||||||
sizeof(int32_t) + // x_resolution
|
sizeof(decltype(y_resolution)) +
|
||||||
sizeof(int32_t) + // y_resolution
|
sizeof(decltype(nb_colors)) +
|
||||||
sizeof(uint32_t) + // nb_colors
|
sizeof(decltype(nb_important_colors));
|
||||||
sizeof(uint32_t); // nb_important_colors
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::size_t mBytesPerPixel = 4;
|
static constexpr std::size_t mBytesPerPixel = 4;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Save(aiTexture* texture, IOStream* file);
|
static void Save(aiTexture* texture, IOStream* file);
|
||||||
|
|
Loading…
Reference in New Issue