2017-06-01 21:55:10 +02:00
|
|
|
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
2016-05-04 19:24:41 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
|
|
|
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
|
|
|
*
|
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
|
|
|
*****************************************************************************/
|
|
|
|
#pragma endregion
|
|
|
|
|
2017-01-07 13:10:42 +01:00
|
|
|
#pragma once
|
2015-12-29 15:32:51 +01:00
|
|
|
|
2018-05-07 22:32:24 +02:00
|
|
|
#include <memory>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
2018-05-07 19:45:15 +02:00
|
|
|
#include "../common.h"
|
2017-06-09 00:02:39 +02:00
|
|
|
|
2018-03-13 13:14:02 +01:00
|
|
|
struct rct_drawpixelinfo;
|
|
|
|
struct rct_palette;
|
2015-12-29 17:21:08 +01:00
|
|
|
|
2018-05-07 22:32:24 +02:00
|
|
|
enum class IMAGE_FORMAT
|
|
|
|
{
|
|
|
|
UNKNOWN,
|
|
|
|
AUTOMATIC, // Automatically detect from file extension
|
|
|
|
BITMAP,
|
|
|
|
PNG,
|
|
|
|
PNG_32, // Force load to 32bpp buffer
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Image
|
|
|
|
{
|
|
|
|
// Meta
|
|
|
|
uint32 Width{};
|
|
|
|
uint32 Height{};
|
|
|
|
uint32 Depth{};
|
|
|
|
|
|
|
|
// Data
|
|
|
|
std::vector<uint8> Pixels;
|
|
|
|
std::unique_ptr<rct_palette> Palette;
|
|
|
|
uint32 Stride{};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-01-07 13:10:42 +01:00
|
|
|
namespace Imaging
|
|
|
|
{
|
2018-05-08 22:41:41 +02:00
|
|
|
IMAGE_FORMAT GetImageFormatFromPath(const std::string_view& path);
|
2018-05-07 22:32:24 +02:00
|
|
|
Image ReadFromFile(const std::string_view& path, IMAGE_FORMAT format = IMAGE_FORMAT::AUTOMATIC);
|
|
|
|
Image ReadFromBuffer(const std::vector<uint8>& buffer, IMAGE_FORMAT format = IMAGE_FORMAT::AUTOMATIC);
|
|
|
|
void WriteToFile(const std::string_view& path, const Image& image, IMAGE_FORMAT format = IMAGE_FORMAT::AUTOMATIC);
|
2017-01-07 13:10:42 +01:00
|
|
|
}
|