add YAZE_LIB_PNG if directives
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
#if YAZE_LIB_PNG == 1
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -187,6 +189,11 @@ void ConvertPngToSurface(const std::vector<uint8_t> &png_data,
|
|||||||
SDL_Log("Successfully created SDL_Surface from PNG data");
|
SDL_Log("Successfully created SDL_Surface from PNG data");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> Bitmap::GetPngData() {
|
||||||
|
ConvertSurfaceToPNG(surface_.get(), png_data_);
|
||||||
|
return png_data_;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // YAZE_LIB_PNG
|
#endif // YAZE_LIB_PNG
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -214,11 +221,6 @@ Uint32 GetSnesPixelFormat(int format) {
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::vector<uint8_t> Bitmap::GetPngData() {
|
|
||||||
ConvertSurfaceToPNG(surface_.get(), png_data_);
|
|
||||||
return png_data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Bitmap::SaveSurfaceToFile(std::string_view filename) {
|
void Bitmap::SaveSurfaceToFile(std::string_view filename) {
|
||||||
SDL_SaveBMP(surface_.get(), filename.data());
|
SDL_SaveBMP(surface_.get(), filename.data());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ enum BitmapFormat {
|
|||||||
k8bpp = 3,
|
k8bpp = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if YAZE_LIB_PNG == 1
|
||||||
/**
|
/**
|
||||||
* @brief Convert SDL_Surface to PNG image data.
|
* @brief Convert SDL_Surface to PNG image data.
|
||||||
*/
|
*/
|
||||||
@@ -56,6 +57,7 @@ bool ConvertSurfaceToPNG(SDL_Surface *surface, std::vector<uint8_t> &buffer);
|
|||||||
*/
|
*/
|
||||||
void ConvertPngToSurface(const std::vector<uint8_t> &png_data,
|
void ConvertPngToSurface(const std::vector<uint8_t> &png_data,
|
||||||
SDL_Surface **outSurface);
|
SDL_Surface **outSurface);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Represents a bitmap image.
|
* @brief Represents a bitmap image.
|
||||||
@@ -87,7 +89,10 @@ class Bitmap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if YAZE_LIB_PNG == 1
|
||||||
std::vector<uint8_t> GetPngData();
|
std::vector<uint8_t> GetPngData();
|
||||||
|
#endif
|
||||||
|
|
||||||
void SaveSurfaceToFile(std::string_view filename);
|
void SaveSurfaceToFile(std::string_view filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user