yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
pixel_clipboard.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_GRAPHICS_PIXEL_CLIPBOARD_H
2#define YAZE_APP_EDITOR_GRAPHICS_PIXEL_CLIPBOARD_H
3
4#include <array>
5#include <cstdint>
6#include <string>
7#include <vector>
8
9#include "absl/status/statusor.h"
10
11namespace yaze::editor {
12
14using SheetColors = std::array<std::array<uint8_t, 3>, 8>;
15
18absl::StatusOr<std::vector<uint8_t>> EncodeClipboardPng(
19 const std::vector<uint8_t>& indices, int width, int height,
20 const SheetColors& colors);
21
24 int width = 0;
25 int height = 0;
26 std::vector<uint8_t> indices; // 0-7, row-major
27 int kept = 0; // indexed pixels kept as they were (indices 0-7)
28 int exact = 0; // pixels whose color matched a sheet color exactly
29 int remapped = 0; // pixels given the nearest sheet color
30 int transparent = 0; // pixels with alpha below 128, mapped to 0
31 int above_depth = 0; // indexed pixels that used an index above 7
32};
33
40absl::StatusOr<ClipboardPaste> MapClipboardPng(
41 const std::vector<uint8_t>& png_bytes, const SheetColors& colors,
42 int max_width = 128, int max_height = 32);
43
45std::string DescribeClipboardPaste(const ClipboardPaste& paste);
46
47} // namespace yaze::editor
48
49#endif // YAZE_APP_EDITOR_GRAPHICS_PIXEL_CLIPBOARD_H
Editors are the view controllers for the application.
absl::StatusOr< ClipboardPaste > MapClipboardPng(const std::vector< uint8_t > &png_bytes, const SheetColors &colors, int max_width, int max_height)
std::array< std::array< uint8_t, 3 >, 8 > SheetColors
The 8 colors a 3bpp sheet shows (index 0 is transparent in game).
absl::StatusOr< std::vector< uint8_t > > EncodeClipboardPng(const std::vector< uint8_t > &indices, int width, int height, const SheetColors &colors)
std::string DescribeClipboardPaste(const ClipboardPaste &paste)
"16x16: 200 kept" / "16x8: 90 exact, 38 remapped, 4 above color 7".
A clipboard PNG mapped onto a sheet's colors.
std::vector< uint8_t > indices