summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/png.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/util/png.h')
-rw-r--r--src/lib/util/png.h46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/lib/util/png.h b/src/lib/util/png.h
index 784c92646e6..2f9b7ac29cb 100644
--- a/src/lib/util/png.h
+++ b/src/lib/util/png.h
@@ -14,13 +14,14 @@
#pragma once
#include "bitmap.h"
-#include "corefile.h"
-#include "osdcore.h"
+#include "utilfwd.h"
#include <cstdint>
#include <list>
#include <memory>
#include <string>
+#include <string_view>
+#include <system_error>
#include <utility>
@@ -31,12 +32,9 @@ namespace util {
***************************************************************************/
/* Error types */
-enum class png_error
+enum class png_error : int
{
- NONE,
- OUT_OF_MEMORY,
- UNKNOWN_FILTER,
- FILE_ERROR,
+ UNKNOWN_FILTER = 1,
BAD_SIGNATURE,
DECOMPRESS_ERROR,
FILE_TRUNCATED,
@@ -46,6 +44,9 @@ enum class png_error
UNSUPPORTED_FORMAT
};
+std::error_category const &png_category() noexcept;
+inline std::error_condition make_error_condition(png_error err) noexcept { return std::error_condition(int(err), png_category()); }
+
/***************************************************************************
@@ -59,16 +60,16 @@ public:
~png_info() { free_data(); }
- png_error read_file(core_file &fp);
- png_error copy_to_bitmap(bitmap_argb32 &bitmap, bool &hasalpha);
- png_error expand_buffer_8bit();
+ std::error_condition read_file(read_stream &fp) noexcept;
+ std::error_condition copy_to_bitmap(bitmap_argb32 &bitmap, bool &hasalpha) noexcept;
+ std::error_condition expand_buffer_8bit() noexcept;
- png_error add_text(char const *keyword, char const *text);
+ std::error_condition add_text(std::string_view keyword, std::string_view text) noexcept;
- void free_data();
- void reset() { free_data(); operator=(png_info()); }
+ void free_data() noexcept;
+ void reset() noexcept { free_data(); operator=(png_info()); }
- static png_error verify_header(core_file &fp);
+ static std::error_condition verify_header(read_stream &fp) noexcept;
std::unique_ptr<std::uint8_t []> image;
std::uint32_t width, height;
@@ -101,14 +102,21 @@ private:
FUNCTION PROTOTYPES
***************************************************************************/
-png_error png_read_bitmap(core_file &fp, bitmap_argb32 &bitmap);
+std::error_condition png_read_bitmap(read_stream &fp, bitmap_argb32 &bitmap) noexcept;
-png_error png_write_bitmap(core_file &fp, png_info *info, bitmap_t const &bitmap, int palette_length, const rgb_t *palette);
+std::error_condition png_write_bitmap(random_write &fp, png_info *info, bitmap_t const &bitmap, int palette_length, const rgb_t *palette) noexcept;
-png_error mng_capture_start(core_file &fp, bitmap_t &bitmap, unsigned rate);
-png_error mng_capture_frame(core_file &fp, png_info &info, bitmap_t const &bitmap, int palette_length, const rgb_t *palette);
-png_error mng_capture_stop(core_file &fp);
+std::error_condition mng_capture_start(random_write &fp, bitmap_t const &bitmap, unsigned rate) noexcept;
+std::error_condition mng_capture_frame(random_write &fp, png_info &info, bitmap_t const &bitmap, int palette_length, rgb_t const *palette) noexcept;
+std::error_condition mng_capture_stop(random_write &fp) noexcept;
} // namespace util
+
+namespace std {
+
+template <> struct is_error_condition_enum<util::png_error> : public std::true_type { };
+
+} // namespace std
+
#endif // MAME_LIB_UTIL_PNG_H