39 load(nbfs, nbfp, width, height);
49 if (nbfs.
size() != (width * height))
52 if ((width >= 0x8000) || (height >= 0x8000))
55 if (nbfp.
size() > 512)
62 e.
add(
"Failed reading NBFS file");
69 std::memset(palette.
get(), 0, 768);
71 const size_t count = MIN<size_t>(nbfp.
size() / 2, 256) * 3;
72 for (
size_t i = 0; i < count; i += 3) {
75 palette[i + 0] = ((color >> 10) & 0x1F) << 3;
76 palette[i + 1] = ((color >> 5) & 0x1F) << 3;
77 palette[i + 2] = ( color & 0x1F) << 3;
94 _mipMaps.back()->size = width * height * 4;
98 bool is0Transp = (palette[0] == 0xF8) && (palette[1] == 0x00) && (palette[2] == 0xF8);
101 for (
uint32 i = 0; i < (width * height); i++, data += 4) {
104 data[0] = palette[pixel * 3 + 0];
105 data[1] = palette[pixel * 3 + 1];
106 data[2] = palette[pixel * 3 + 2];
107 data[3] = ((pixel == 0) && is0Transp) ? 0x00 : 0xFF;
uint16 readUint16LE()
Read an unsigned 16-bit word stored in little endian (LSB first) order from the stream and return it...
void add(const char *s,...) GCC_PRINTF(2
PointerType release()
Returns the plain pointer value and releases ScopedPtr.
void load(Common::SeekableReadStream &nbfs, Common::SeekableReadStream &nbfp, uint32 width, uint32 height)
NBFS(Common::SeekableReadStream &nbfs, Common::SeekableReadStream &nbfp, uint32 width, uint32 height)
NBFS are raw paletted images and need a palette, width and height.
Exception that provides a stack of explanations.
A simple scoped smart pointer template.
Basic exceptions to throw.
Utility templates and functions.
PixelFormatRaw _formatRaw
virtual size_t size() const =0
Obtains the total size of the stream, measured in bytes.
Basic reading stream interfaces.
PointerType get() const
Returns the plain pointer value.
const byte * readPalette(Common::SeekableReadStream &nbfp)
Nitro Basic File Screen, a simple raw Nintendo DS image.
Interface for a seekable & readable data stream.
byte readByte()
Read an unsigned byte from the stream and return it.
void readImage(Common::SeekableReadStream &nbfs, const byte *palette, uint32 width, uint32 height)