| 3287 | } |
| 3288 | |
| 3289 | static QVariant interpret(const ResourceFormat &f, uint16_t comp) |
| 3290 | { |
| 3291 | if(f.compByteWidth != 2 || f.compType == CompType::Float) |
| 3292 | return QVariant(); |
| 3293 | |
| 3294 | if(f.compType == CompType::SInt) |
| 3295 | { |
| 3296 | return (int16_t)comp; |
| 3297 | } |
| 3298 | else if(f.compType == CompType::UInt) |
| 3299 | { |
| 3300 | return comp; |
| 3301 | } |
| 3302 | else if(f.compType == CompType::SScaled) |
| 3303 | { |
| 3304 | return (float)((int16_t)comp); |
| 3305 | } |
| 3306 | else if(f.compType == CompType::UScaled) |
| 3307 | { |
| 3308 | return (float)comp; |
| 3309 | } |
| 3310 | else if(f.compType == CompType::UNorm || f.compType == CompType::UNormSRGB) |
| 3311 | { |
| 3312 | return (float)comp / (float)0xffff; |
| 3313 | } |
| 3314 | else if(f.compType == CompType::SNorm) |
| 3315 | { |
| 3316 | int16_t cast = (int16_t)comp; |
| 3317 | |
| 3318 | float ret = -1.0f; |
| 3319 | |
| 3320 | if(cast == -32768) |
| 3321 | ret = -1.0f; |
| 3322 | else |
| 3323 | ret = ((float)cast) / 32767.0f; |
| 3324 | |
| 3325 | return ret; |
| 3326 | } |
| 3327 | |
| 3328 | return QVariant(); |
| 3329 | } |
| 3330 | |
| 3331 | static QVariant interpret(const ResourceFormat &f, byte comp) |
| 3332 | { |