1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #ifndef OLC_PGE_SPRITE
- #define OLC_PGE_SPRITE
-
- #ifdef _WIN32
- // Link to libraries
- #ifndef __MINGW32__
- #pragma comment(lib, "user32.lib") // Visual Studio Only
- #pragma comment(lib, "gdi32.lib") // For other Windows Compilers please add
- #pragma comment(lib, "gdiplus.lib") // these libs to your linker input
- #else
- // In Code::Blocks, Select C++14 in your build options, and add the
- // following libs to your linker: user32 gdi32 opengl32 gdiplus
- #if !defined _WIN32_WINNT
- #ifdef HAVE_MSMF
- #define _WIN32_WINNT 0x0600 // Windows Vista
- #else
- #define _WIN32_WINNT 0x0500 // Windows 2000
- #endif
- #endif
- #endif
- // Include WinAPI
- #include <windows.h>
- #include <gdiplus.h>
- #else
- #include <png.h>
- #endif
-
- #include <cstdint>
- #include <cmath>
- #include <string>
- #include <map>
- #include <vector>
- #include <streambuf>
- #include <iostream>
- #include <fstream>
- #include "olcPGE_Common.h"
- #include "olcPGE_Pixel.h"
- #include "olcPGE_ResourcePack.h"
-
- namespace olc {
- // A bitmap-like structure that stores a 2D array of Pixels
- class Sprite
- {
- public:
- Sprite();
- Sprite(std::string sImageFile);
- Sprite(std::string sImageFile, olc::ResourcePack *pack);
- Sprite(int32_t w, int32_t h);
- ~Sprite();
-
- public:
- olc::rcode LoadFromFile(std::string sImageFile, olc::ResourcePack *pack = nullptr);
- olc::rcode LoadFromPGESprFile(std::string sImageFile, olc::ResourcePack *pack = nullptr);
- olc::rcode SaveToPGESprFile(std::string sImageFile);
-
- public:
- int32_t width = 0;
- int32_t height = 0;
- enum Mode { NORMAL, PERIODIC };
-
- public:
- void SetSampleMode(olc::Sprite::Mode mode = olc::Sprite::Mode::NORMAL);
- Pixel GetPixel(int32_t x, int32_t y);
- bool SetPixel(int32_t x, int32_t y, Pixel p);
-
- Pixel Sample(float x, float y);
- Pixel SampleBL(float u, float v);
- Pixel* GetData();
-
- private:
- Pixel *pColData = nullptr;
- Mode modeSample = Mode::NORMAL;
-
- #ifdef OLC_DBG_OVERDRAW
- public:
- static int nOverdrawCount;
- #endif
- };
- }
- #endif
|