Path: blob/master/RSDKv5/RSDK/Graphics/Sprite.hpp
1167 views
#ifndef SPRITE_H1#define SPRITE_H23namespace RSDK4{56struct Image {7Image()8{9InitFileInfo(&info);10width = 0;11height = 0;12palette = NULL;13pixels = NULL;14}15#if !RETRO_USE_ORIGINAL_CODE16~Image() { RemoveStorageEntry((void **)&palette); }17#endif1819virtual bool32 Load(const char *fileName, bool32 loadHeader) { return false; }20virtual bool32 Load(String *fileName, bool32 loadHeader)21{22if (!fileName->chars)23return Load("", loadHeader);2425GetCString(textBuffer, fileName);26return Load(textBuffer, loadHeader);27}28virtual void Close() { CloseFile(&info); }2930FileInfo info;31int32 width;32int32 height;33int32 depth;34color *palette;35uint8 *pixels;36};3738struct GifDecoder {39int32 depth;40int32 clearCode;41int32 eofCode;42int32 runningCode;43int32 runningBits;44int32 prevCode;45int32 currentCode;46int32 maxCodePlusOne;47int32 stackPtr;48int32 shiftState;49int32 fileState;50int32 position;51int32 bufferSize;52uint32 shiftData;53uint32 pixelCount;54uint8 buffer[256];55uint8 stack[4096];56uint8 suffix[4096];57uint32 prefix[4096];58};5960struct ImageGIF : public Image {61ImageGIF() { AllocateStorage((void **)&decoder, sizeof(GifDecoder), DATASET_TMP, true); }62#if !RETRO_USE_ORIGINAL_CODE63~ImageGIF() { RemoveStorageEntry((void **)&decoder); }64#endif6566bool32 Load(const char *fileName, bool32 loadHeader);6768GifDecoder *decoder;69};7071#if RETRO_REV0272enum PNGColorFormats {73PNGCLR_GREYSCALE = 0,74PNGCLR_RGB = 2,75PNGCLR_INDEXED = 3,76PNGCLR_GREYSCALEA = 4,77PNGCLR_RGBA = 6,78};7980enum PNGCompressionFilters {81PNGFILTER_NONE,82PNGFILTER_SUB,83PNGFILTER_UP,84PNGFILTER_AVG,85PNGFILTER_PAETH,86};8788struct ImagePNG : public Image {89bool32 Load(const char *fileName, bool32 loadHeader);9091void UnpackPixels_Greyscale(uint8 *pixelData);92void UnpackPixels_GreyscaleA(uint8 *pixelData);93void UnpackPixels_Indexed(uint8 *pixelData);94void UnpackPixels_RGB(uint8 *pixelData);95void UnpackPixels_RGBA(uint8 *pixelData);9697void Unfilter(uint8 *recon);9899bool32 AllocatePixels();100void ProcessScanlines();101102uint8 bitDepth;103uint8 colorFormat;104uint8 compression;105uint8 filter;106uint8 interlaced;107int32 chunkHeader;108int32 chunkSize;109int32 chunkCRC;110int32 dataSize;111uint8 *chunkBuffer;112};113#else114struct ImageTGA : public Image {115bool32 Load(const char *fileName, bool32 loadHeader);116};117#endif118119uint16 LoadSpriteSheet(const char *filename, uint8 scope);120bool32 LoadImage(const char *filename, double displayLength, double fadeSpeed, bool32 (*skipCallback)());121122#if RETRO_REV0U123#include "Legacy/SpriteLegacy.hpp"124#endif125126} // namespace RSDK127128#endif // SPRITE_H129130