Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
LegacyBitmap.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <expected>
6#include <filesystem>
7#include <span>
8#include <string>
9#include <string_view>
10#include <vector>
11
12namespace monopoly::data
13{
32
33
35 {
37 std::filesystem::path path;
38 std::string detail;
39 };
40
41
43 {
44 std::uint32_t declaredFileSize{};
45 std::uint32_t pixelDataOffset{};
46 std::uint32_t dibHeaderSize{};
47 std::int32_t width{};
48 std::int32_t height{};
49 std::uint16_t bitsPerPixel{};
50 std::uint32_t compression{};
51 std::uint32_t declaredImageSize{};
52
53 [[nodiscard]] constexpr bool topDown() const noexcept
54 {
55 return height < 0;
56 }
57 };
58
59
60 [[nodiscard]] std::string_view bitmapErrorCodeName(
61 BitmapErrorCode code) noexcept;
62
64 {
65 std::uint32_t width{};
66 std::uint32_t height{};
67 std::vector<std::uint8_t> pixels; // top-down, straight RGBA8
68 };
69
71 {
72 std::uint16_t width{};
73 std::uint16_t height{};
74 std::int16_t originX{};
75 std::int16_t originY{};
76 std::uint32_t flags{};
77 std::uint16_t colourCount{};
78 std::uint16_t alphaCount{};
79 std::size_t pixelDataOffset{};
80 std::size_t rowStride{};
81 };
82
83 // NEWBITMAPHEADER / DataUAP contract from L_Type.h. UAP raster is
84 // top-down and each 8-bit row is DWORD padded.
85 [[nodiscard]] std::expected<LegacyUapMetadata, BitmapError>
86 inspectLegacyUap(std::span<const std::byte> bytes);
87
88 [[nodiscard]] std::expected<LegacyBitmapRGBA8, BitmapError>
89 decodeLegacyUapRGBA8(std::span<const std::byte> bytes,
90 std::size_t maxPixels = 16U * 1024U * 1024U);
91
92 // BI_RGB 8/24 only. BMP reserved palette bytes are not alpha.
93 // L_Data.cpp:7490 sets BITMAP_NOTRANSPARENCY for DataBMP.
94 [[nodiscard]] std::expected<LegacyBitmapRGBA8, BitmapError>
95 decodeLegacyBitmapRGBA8(std::span<const std::byte> bytes,
96 std::size_t maxPixels = 16U * 1024U * 1024U);
97
98 // Inspecteur sans SDL/GPU pour prouver les metadonnees des BMP bruts.
99 [[nodiscard]] std::expected<LegacyBitmapMetadata, BitmapError>
100 inspectLegacyBitmap(std::span<const std::byte> bytes);
101
102 [[nodiscard]] std::expected<LegacyBitmapMetadata, BitmapError>
103 inspectLegacyBitmapFile(const std::filesystem::path& path);
104}
std::vector< std::byte > bytes
unsigned index
std::string path
std::string_view bitmapErrorCodeName(BitmapErrorCode code) noexcept
std::expected< LegacyBitmapMetadata, BitmapError > inspectLegacyBitmapFile(const std::filesystem::path &path)
std::expected< LegacyUapMetadata, BitmapError > inspectLegacyUap(std::span< const std::byte > bytes)
std::expected< LegacyBitmapRGBA8, BitmapError > decodeLegacyUapRGBA8(std::span< const std::byte > bytes, std::size_t maxPixels)
std::expected< LegacyBitmapRGBA8, BitmapError > decodeLegacyBitmapRGBA8(std::span< const std::byte > bytes, std::size_t maxPixels)
std::expected< LegacyBitmapMetadata, BitmapError > inspectLegacyBitmap(std::span< const std::byte > bytes)
std::filesystem::path path
constexpr bool topDown() const noexcept
std::vector< std::uint8_t > pixels