gobj: support T_unsigned_int_24_8 in TexturePeeker

This commit is contained in:
rdb 2018-07-23 08:32:58 +02:00
parent 71e18eb960
commit 1a6d329fde
3 changed files with 23 additions and 0 deletions

View File

@ -2342,6 +2342,24 @@ get_unsigned_int(const unsigned char *&p) {
return (double)v.ui / 4294967295.0;
}
/**
* This is used by store() to retrieve the next consecutive component value
* from the indicated element of the array, which is taken to be an array of
* unsigned ints with the value packed in the 24 least significant bits.
*/
INLINE double Texture::
get_unsigned_int_24(const unsigned char *&p) {
union {
uint32_t ui;
uint8_t uc[4];
} v;
v.uc[0] = (*p++);
v.uc[1] = (*p++);
v.uc[2] = (*p++);
v.uc[3] = (*p++);
return (double)(v.ui & 0xffffff) / (double)0xffffff;
}
/**
* This is used by store() to retrieve the next consecutive component value
* from the indicated element of the array, which is taken to be an array of

View File

@ -858,6 +858,7 @@ private:
INLINE static double get_unsigned_byte(const unsigned char *&p);
INLINE static double get_unsigned_short(const unsigned char *&p);
INLINE static double get_unsigned_int(const unsigned char *&p);
INLINE static double get_unsigned_int_24(const unsigned char *&p);
INLINE static double get_float(const unsigned char *&p);
INLINE static double get_half_float(const unsigned char *&p);

View File

@ -94,6 +94,10 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) {
_get_component = Texture::get_half_float;
break;
case Texture::T_unsigned_int_24_8:
_get_component = Texture::get_unsigned_int_24;
break;
default:
// Not supported.
_image.clear();