yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
sheet_image_import.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_GRAPHICS_SHEET_IMAGE_IMPORT_H
2#define YAZE_APP_EDITOR_GRAPHICS_SHEET_IMAGE_IMPORT_H
3
4#include <array>
5#include <cstdint>
6#include <string>
7#include <string_view>
8#include <vector>
9
10#include "absl/status/statusor.h"
11#include "util/indexed_png.h"
12
13namespace yaze::editor {
14
34 kIndexedPng, // indices and PLTE order taken from the file
35 kPaletteStrip, // RGB pixels matched exactly against a palette strip
36};
37
39 int width = 0;
40 int height = 0; // art only, without the palette strip
41 std::vector<uint8_t> indices; // width * height, row-major
42 // Index order. For a palette strip, the strip's colors; for an indexed PNG,
43 // its PLTE (with tRNS alpha).
44 std::vector<std::array<uint8_t, 4>> palette;
46 bool strip_removed = false;
47 int max_index = 0; // highest index the art uses
48};
49
51absl::StatusOr<ImportedSheetImage> ImportSheetImage(const util::PngImage& png);
52
54absl::StatusOr<ImportedSheetImage> ImportSheetImagePng(
55 const std::vector<uint8_t>& png_bytes);
56
60absl::StatusOr<std::vector<uint8_t>> EncodeImportedSheetTiles(
61 const ImportedSheetImage& image, int bpp);
62
64absl::StatusOr<std::vector<uint8_t>> EncodeImportedSheetPng(
65 const ImportedSheetImage& image);
66
68std::string DescribeImportedSheetImage(const ImportedSheetImage& image);
69
73absl::StatusOr<std::vector<int>> PreviewPaletteSlots(
74 std::string_view group_name, size_t palette_size, int row, int count);
75
76} // namespace yaze::editor
77
78#endif // YAZE_APP_EDITOR_GRAPHICS_SHEET_IMAGE_IMPORT_H
Editors are the view controllers for the application.
std::string DescribeImportedSheetImage(const ImportedSheetImage &image)
"128x32 indexed PNG, 8 colors (strip removed), highest index 7".
absl::StatusOr< ImportedSheetImage > ImportSheetImagePng(const std::vector< uint8_t > &png_bytes)
Decodes PNG bytes (file or clipboard) and calls ImportSheetImage.
absl::StatusOr< std::vector< uint8_t > > EncodeImportedSheetTiles(const ImportedSheetImage &image, int bpp)
absl::StatusOr< std::vector< int > > PreviewPaletteSlots(std::string_view group_name, size_t palette_size, int row, int count)
absl::StatusOr< ImportedSheetImage > ImportSheetImage(const util::PngImage &png)
Converts a decoded PNG without re-quantizing it.
absl::StatusOr< std::vector< uint8_t > > EncodeImportedSheetPng(const ImportedSheetImage &image)
Re-encodes the art (without the strip) as an indexed PNG in index order.
std::vector< std::array< uint8_t, 4 > > palette
A decoded PNG: palette indices for indexed files, RGBA otherwise.
Definition indexed_png.h:21