yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
bpp_format_ui.cc
Go to the documentation of this file.
1#include "bpp_format_ui.h"
2#include "util/i18n/tr.h"
3
4#include <algorithm>
5#include <sstream>
6
11#include "imgui/imgui.h"
12
13namespace yaze {
14namespace gui {
15
16BppFormatUI::BppFormatUI(const std::string& id)
17 : id_(id),
18 selected_format_(gfx::BppFormat::kBpp8),
19 preview_format_(gfx::BppFormat::kBpp8),
20 show_analysis_(false),
21 show_preview_(false),
22 show_sheet_analysis_(false),
23 format_changed_(false),
24 last_analysis_sheet_("") {}
25
27 gfx::Bitmap* bitmap, const gfx::SnesPalette& palette,
28 std::function<void(gfx::BppFormat)> on_format_changed) {
29 if (!bitmap)
30 return false;
31
32 format_changed_ = false;
33
34 ImGui::BeginGroup();
35 ImGui::Text(tr("BPP Format Selection"));
36 ImGui::Separator();
37
38 // Current format detection
40 bitmap->vector(), bitmap->width(), bitmap->height());
41
42 ImGui::Text(
43 tr("Current Format: %s"),
44 gfx::BppFormatManager::Get().GetFormatInfo(current_format).name.c_str());
45
46 // Format selection
47 ImGui::Text(tr("Target Format:"));
48 ImGui::SameLine();
49
50 const char* format_names[] = {"2BPP", "3BPP", "4BPP", "8BPP"};
51 int current_selection =
52 static_cast<int>(selected_format_) - 2; // Convert to 0-based index
53
54 if (ImGui::Combo("##BppFormat", &current_selection, format_names, 4)) {
55 selected_format_ = static_cast<gfx::BppFormat>(current_selection + 2);
56 format_changed_ = true;
57 }
58
59 // Format information
60 const auto& format_info =
62 ImGui::Text(tr("Max Colors: %d"), format_info.max_colors);
63 ImGui::Text(tr("Bytes per Tile: %d"), format_info.bytes_per_tile);
64 ImGui::Text(tr("Description: %s"), format_info.description.c_str());
65
66 // Conversion efficiency
67 if (current_format != selected_format_) {
68 int efficiency = GetConversionEfficiency(current_format, selected_format_);
69 ImGui::Text(tr("Conversion Efficiency: %d%%"), efficiency);
70
71 ImVec4 efficiency_color;
72 if (efficiency >= 80) {
73 efficiency_color = GetSuccessColor(); // Green
74 } else if (efficiency >= 60) {
75 efficiency_color = GetWarningColor(); // Yellow
76 } else {
77 efficiency_color = GetErrorColor(); // Red
78 }
79 ImGui::TextColored(efficiency_color, tr("Quality: %s"),
80 efficiency >= 80 ? "Excellent"
81 : efficiency >= 60 ? "Good"
82 : "Poor");
83 }
84
85 // Action buttons
86 ImGui::Separator();
87
88 if (ImGui::Button(tr("Convert Format"))) {
89 if (on_format_changed) {
90 on_format_changed(selected_format_);
91 }
92 format_changed_ = true;
93 }
94
95 ImGui::SameLine();
96 if (ImGui::Button(tr("Show Analysis"))) {
98 }
99
100 ImGui::SameLine();
101 if (ImGui::Button(tr("Preview Conversion"))) {
104 }
105
106 ImGui::EndGroup();
107
108 // Analysis panel
109 if (show_analysis_) {
110 RenderAnalysisPanel(*bitmap, palette);
111 }
112
113 // Preview panel
114 if (show_preview_) {
115 RenderConversionPreview(*bitmap, preview_format_, palette);
116 }
117
118 return format_changed_;
119}
120
122 const gfx::SnesPalette& palette) {
123 ImGui::Begin("BPP Format Analysis", &show_analysis_);
124
125 // Basic analysis
127 bitmap.vector(), bitmap.width(), bitmap.height());
128
129 ImGui::Text(
130 tr("Detected Format: %s"),
131 gfx::BppFormatManager::Get().GetFormatInfo(detected_format).name.c_str());
132
133 // Color usage analysis
134 std::vector<int> color_usage(256, 0);
135 for (uint8_t pixel : bitmap.vector()) {
136 color_usage[pixel]++;
137 }
138
139 int used_colors = 0;
140 for (int count : color_usage) {
141 if (count > 0)
142 used_colors++;
143 }
144
145 ImGui::Text(tr("Colors Used: %d / %d"), used_colors,
146 static_cast<int>(palette.size()));
147 ImGui::Text(tr("Color Efficiency: %.1f%%"),
148 (static_cast<float>(used_colors) / palette.size()) * 100.0f);
149
150 // Color usage chart
151 if (ImGui::CollapsingHeader(tr("Color Usage Chart"))) {
152 RenderColorUsageChart(color_usage);
153 }
154
155 // Format recommendations
156 ImGui::Separator();
157 ImGui::Text(tr("Format Recommendations:"));
158
159 if (used_colors <= 4) {
160 ImGui::TextColored(GetSuccessColor(), tr("✓ 2BPP format would be optimal"));
161 } else if (used_colors <= 8) {
162 ImGui::TextColored(GetSuccessColor(), tr("✓ 3BPP format would be optimal"));
163 } else if (used_colors <= 16) {
164 ImGui::TextColored(GetSuccessColor(), tr("✓ 4BPP format would be optimal"));
165 } else {
166 ImGui::TextColored(GetWarningColor(), tr("⚠ 8BPP format is necessary"));
167 }
168
169 // Memory usage comparison
170 if (ImGui::CollapsingHeader(tr("Memory Usage Comparison"))) {
171 const auto& current_info =
172 gfx::BppFormatManager::Get().GetFormatInfo(detected_format);
173 int current_bytes =
174 (bitmap.width() * bitmap.height() * current_info.bits_per_pixel) / 8;
175
176 ImGui::Text(tr("Current Format (%s): %d bytes"), current_info.name.c_str(),
177 current_bytes);
178
179 for (auto format : gfx::BppFormatManager::Get().GetAvailableFormats()) {
180 if (format == detected_format)
181 continue;
182
183 const auto& info = gfx::BppFormatManager::Get().GetFormatInfo(format);
184 int format_bytes =
185 (bitmap.width() * bitmap.height() * info.bits_per_pixel) / 8;
186 float ratio = static_cast<float>(format_bytes) / current_bytes;
187
188 ImGui::Text(tr("%s: %d bytes (%.1fx)"), info.name.c_str(), format_bytes,
189 ratio);
190 }
191 }
192
193 ImGui::End();
194}
195
197 gfx::BppFormat target_format,
198 const gfx::SnesPalette& palette) {
199 ImGui::Begin("BPP Conversion Preview", &show_preview_);
200
202 bitmap.vector(), bitmap.width(), bitmap.height());
203
204 if (current_format == target_format) {
205 ImGui::Text(tr("No conversion needed - formats are identical"));
206 ImGui::End();
207 return;
208 }
209
210 // Convert the bitmap
211 auto converted_data = gfx::BppFormatManager::Get().ConvertFormat(
212 bitmap.vector(), current_format, target_format, bitmap.width(),
213 bitmap.height());
214
215 // Create preview bitmap
216 gfx::Bitmap preview_bitmap(bitmap.width(), bitmap.height(), bitmap.depth(),
217 converted_data, palette);
218
219 // Render side-by-side comparison
220 ImGui::Text(
221 tr("Original (%s) vs Converted (%s)"),
222 gfx::BppFormatManager::Get().GetFormatInfo(current_format).name.c_str(),
223 gfx::BppFormatManager::Get().GetFormatInfo(target_format).name.c_str());
224
225 ImGui::Columns(2, "PreviewColumns");
226
227 // Original
228 ImGui::Text(tr("Original"));
229 if (bitmap.texture()) {
230 ScopedNearestSampling nearest_sampling(ImGui::GetWindowDrawList());
231 ImGui::Image((ImTextureID)(intptr_t)bitmap.texture(),
232 ImVec2(256, 256 * bitmap.height() / bitmap.width()));
233 }
234
235 ImGui::NextColumn();
236
237 // Converted
238 ImGui::Text(tr("Converted"));
239 if (preview_bitmap.texture()) {
240 ScopedNearestSampling nearest_sampling(ImGui::GetWindowDrawList());
241 ImGui::Image(
242 (ImTextureID)(intptr_t)preview_bitmap.texture(),
243 ImVec2(256, 256 * preview_bitmap.height() / preview_bitmap.width()));
244 }
245
246 ImGui::Columns(1);
247
248 // Conversion statistics
249 ImGui::Separator();
250 ImGui::Text(tr("Conversion Statistics:"));
251
252 const auto& from_info =
254 const auto& to_info =
256
257 int from_bytes =
258 (bitmap.width() * bitmap.height() * from_info.bits_per_pixel) / 8;
259 int to_bytes =
260 (bitmap.width() * bitmap.height() * to_info.bits_per_pixel) / 8;
261
262 ImGui::Text(tr("Size: %d bytes -> %d bytes"), from_bytes, to_bytes);
263 ImGui::Text(tr("Compression Ratio: %.2fx"),
264 static_cast<float>(from_bytes) / to_bytes);
265
266 ImGui::End();
267}
268
269void BppFormatUI::RenderSheetAnalysis(const std::vector<uint8_t>& sheet_data,
270 int sheet_id,
271 const gfx::SnesPalette& palette) {
272 std::string analysis_key = "sheet_" + std::to_string(sheet_id);
273
274 // Check if we need to update analysis
275 if (last_analysis_sheet_ != analysis_key) {
277 sheet_data, sheet_id, palette);
278 UpdateAnalysisCache(sheet_id, analysis);
279 last_analysis_sheet_ = analysis_key;
280 }
281
282 auto it = cached_analysis_.find(sheet_id);
283 if (it == cached_analysis_.end())
284 return;
285
286 const auto& analysis = it->second;
287
288 ImGui::Begin("Graphics Sheet Analysis", &show_sheet_analysis_);
289
290 ImGui::Text(tr("Sheet ID: %d"), analysis.sheet_id);
291 ImGui::Text(tr("Original Format: %s"),
293 .GetFormatInfo(analysis.original_format)
294 .name.c_str());
295 ImGui::Text(tr("Current Format: %s"),
297 .GetFormatInfo(analysis.current_format)
298 .name.c_str());
299
300 if (analysis.was_converted) {
301 ImGui::TextColored(GetWarningColor(), tr("⚠ This sheet was converted"));
302 ImGui::Text(tr("Conversion History: %s"),
303 analysis.conversion_history.c_str());
304 } else {
305 ImGui::TextColored(GetSuccessColor(), tr("✓ Original format preserved"));
306 }
307
308 ImGui::Separator();
309 ImGui::Text(tr("Color Usage: %d / %d colors used"),
310 analysis.palette_entries_used, static_cast<int>(palette.size()));
311 ImGui::Text(tr("Compression Ratio: %.2fx"), analysis.compression_ratio);
312 ImGui::Text(tr("Size: %zu -> %zu bytes"), analysis.original_size,
313 analysis.current_size);
314
315 // Tile usage pattern
316 if (ImGui::CollapsingHeader(tr("Tile Usage Pattern"))) {
317 int total_tiles = analysis.tile_usage_pattern.size();
318 int used_tiles = 0;
319 int empty_tiles = 0;
320
321 for (int usage : analysis.tile_usage_pattern) {
322 if (usage > 0) {
323 used_tiles++;
324 } else {
325 empty_tiles++;
326 }
327 }
328
329 ImGui::Text(tr("Total Tiles: %d"), total_tiles);
330 ImGui::Text(tr("Used Tiles: %d (%.1f%%)"), used_tiles,
331 (static_cast<float>(used_tiles) / total_tiles) * 100.0f);
332 ImGui::Text(tr("Empty Tiles: %d (%.1f%%)"), empty_tiles,
333 (static_cast<float>(empty_tiles) / total_tiles) * 100.0f);
334 }
335
336 // Recommendations
337 ImGui::Separator();
338 ImGui::Text(tr("Recommendations:"));
339
340 if (analysis.was_converted && analysis.palette_entries_used <= 16) {
341 ImGui::TextColored(
343 tr("✓ Consider reverting to %s format for better compression"),
345 .GetFormatInfo(analysis.original_format)
346 .name.c_str());
347 }
348
349 if (analysis.palette_entries_used < static_cast<int>(palette.size()) / 2) {
350 ImGui::TextColored(
352 tr("⚠ Palette is underutilized - consider optimization"));
353 }
354
355 ImGui::End();
356}
357
359 gfx::BppFormat to_format) const {
360 // All conversions are available in our implementation
361 return from_format != to_format;
362}
363
365 gfx::BppFormat to_format) const {
366 // Calculate efficiency based on format compatibility
367 if (from_format == to_format)
368 return 100;
369
370 // Higher BPP to lower BPP conversions may lose quality
371 if (static_cast<int>(from_format) > static_cast<int>(to_format)) {
372 int bpp_diff = static_cast<int>(from_format) - static_cast<int>(to_format);
373 return std::max(
374 20, 100 - (bpp_diff * 20)); // Reduce efficiency by 20% per BPP level
375 }
376
377 // Lower BPP to higher BPP conversions are lossless
378 return 100;
379}
380
382 ImGui::Text(tr("Format: %s"), info.name.c_str());
383 ImGui::Text(tr("Bits per Pixel: %d"), info.bits_per_pixel);
384 ImGui::Text(tr("Max Colors: %d"), info.max_colors);
385 ImGui::Text(tr("Bytes per Tile: %d"), info.bytes_per_tile);
386 ImGui::Text(tr("Compressed: %s"), info.is_compressed ? "Yes" : "No");
387 ImGui::Text(tr("Description: %s"), info.description.c_str());
388}
389
390void BppFormatUI::RenderColorUsageChart(const std::vector<int>& color_usage) {
391 // Find maximum usage for scaling
392 int max_usage = *std::max_element(color_usage.begin(), color_usage.end());
393 if (max_usage == 0)
394 return;
395
396 // Render simple bar chart
397 ImGui::Text(tr("Color Usage Distribution:"));
398
399 for (size_t i = 0; i < std::min(color_usage.size(), size_t(16)); ++i) {
400 if (color_usage[i] > 0) {
401 float usage_ratio = static_cast<float>(color_usage[i]) / max_usage;
402 ImGui::Text(tr("Color %zu: %d pixels (%.1f%%)"), i, color_usage[i],
403 (static_cast<float>(color_usage[i]) / (16 * 16)) * 100.0f);
404 ImGui::SameLine();
405 ImGui::ProgressBar(usage_ratio, ImVec2(100, 0));
406 }
407 }
408}
409
410void BppFormatUI::RenderConversionHistory(const std::string& history) {
411 ImGui::Text(tr("Conversion History:"));
412 ImGui::TextWrapped("%s", history.c_str());
413}
414
418
420 switch (format) {
422 return ImVec4(1, 0, 0, 1); // Red
424 return ImVec4(1, 1, 0, 1); // Yellow
426 return ImVec4(0, 1, 0, 1); // Green
428 return ImVec4(0, 0, 1, 1); // Blue
429 default:
430 return ImVec4(1, 1, 1, 1); // White
431 }
432}
433
435 int sheet_id, const gfx::GraphicsSheetAnalysis& analysis) {
436 cached_analysis_[sheet_id] = analysis;
437}
438
439// BppConversionDialog implementation
440
442 : id_(id),
443 is_open_(false),
444 target_format_(gfx::BppFormat::kBpp8),
445 preserve_palette_(true),
446 preview_valid_(false),
447 show_preview_(true),
448 preview_scale_(1.0f) {}
449
451 const gfx::Bitmap& bitmap, const gfx::SnesPalette& palette,
452 std::function<void(gfx::BppFormat, bool)> on_convert) {
453 source_bitmap_ = bitmap;
454 source_palette_ = palette;
455 convert_callback_ = on_convert;
456 is_open_ = true;
457 preview_valid_ = false;
458}
459
461 if (!is_open_)
462 return false;
463
464 ImGui::OpenPopup("BPP Format Conversion");
465
466 if (ImGui::BeginPopupModal("BPP Format Conversion", &is_open_,
467 ImGuiWindowFlags_AlwaysAutoResize)) {
469 ImGui::Separator();
471 ImGui::Separator();
472
473 if (show_preview_) {
475 ImGui::Separator();
476 }
477
479
480 ImGui::EndPopup();
481 }
482
483 return is_open_;
484}
485
487 if (preview_valid_)
488 return;
489
492
493 if (current_format == target_format_) {
495 preview_valid_ = true;
496 return;
497 }
498
499 auto converted_data = gfx::BppFormatManager::Get().ConvertFormat(
500 source_bitmap_.vector(), current_format, target_format_,
502
505 source_bitmap_.depth(), converted_data, source_palette_);
506 preview_valid_ = true;
507}
508
510 ImGui::Text(tr("Convert to BPP Format:"));
511
512 const char* format_names[] = {"2BPP", "3BPP", "4BPP", "8BPP"};
513 int current_selection = static_cast<int>(target_format_) - 2;
514
515 if (ImGui::Combo("##TargetFormat", &current_selection, format_names, 4)) {
516 target_format_ = static_cast<gfx::BppFormat>(current_selection + 2);
517 preview_valid_ = false; // Invalidate preview
518 }
519
520 const auto& format_info =
522 ImGui::Text(tr("Max Colors: %d"), format_info.max_colors);
523 ImGui::Text(tr("Description: %s"), format_info.description.c_str());
524}
525
527 if (ImGui::Button(tr("Update Preview"))) {
528 preview_valid_ = false;
529 }
530
532
534 ImGui::Text(tr("Preview:"));
535 {
536 ScopedNearestSampling nearest_sampling(ImGui::GetWindowDrawList());
537 ImGui::Image((ImTextureID)(intptr_t)preview_bitmap_.texture(),
538 ImVec2(128 * preview_scale_, 128 * preview_scale_));
539 }
540
541 ImGui::SliderFloat(tr("Scale"), &preview_scale_, 0.5f, 3.0f);
542 }
543}
544
546 ImGui::Checkbox(tr("Preserve Palette"), &preserve_palette_);
547 ImGui::SameLine();
548 ImGui::Checkbox(tr("Show Preview"), &show_preview_);
549}
550
552 if (ImGui::Button(tr("Convert"))) {
553 if (convert_callback_) {
555 }
556 is_open_ = false;
557 }
558
559 ImGui::SameLine();
560 if (ImGui::Button(tr("Cancel"))) {
561 is_open_ = false;
562 }
563}
564
565// BppComparisonTool implementation
566
568 : id_(id),
569 is_open_(false),
570 has_source_(false),
571 comparison_scale_(1.0f),
572 show_metrics_(true),
573 selected_comparison_(gfx::BppFormat::kBpp8) {}
574
576 const gfx::SnesPalette& palette) {
577 source_bitmap_ = bitmap;
578 source_palette_ = palette;
579 has_source_ = true;
581}
582
584 if (!is_open_ || !has_source_)
585 return;
586
587 ImGui::Begin("BPP Format Comparison", &is_open_);
588
590 ImGui::Separator();
592
593 if (show_metrics_) {
594 ImGui::Separator();
596 }
597
598 ImGui::End();
599}
600
604
605 for (auto format : gfx::BppFormatManager::Get().GetAvailableFormats()) {
606 if (format == source_format) {
609 comparison_valid_[format] = true;
610 continue;
611 }
612
613 try {
614 auto converted_data = gfx::BppFormatManager::Get().ConvertFormat(
615 source_bitmap_.vector(), source_format, format,
617
618 comparison_bitmaps_[format] =
620 source_bitmap_.depth(), converted_data, source_palette_);
622 comparison_valid_[format] = true;
623 } catch (...) {
624 comparison_valid_[format] = false;
625 }
626 }
627}
628
630 ImGui::Text(tr("Format Comparison (Scale: %.1fx)"), comparison_scale_);
631 ImGui::SliderFloat("##Scale", &comparison_scale_, 0.5f, 3.0f);
632
633 ImGui::Columns(2, "ComparisonColumns");
634
635 for (auto format : gfx::BppFormatManager::Get().GetAvailableFormats()) {
636 auto it = comparison_bitmaps_.find(format);
637 if (it == comparison_bitmaps_.end() || !comparison_valid_[format])
638 continue;
639
640 const auto& bitmap = it->second;
641 const auto& format_info =
643
644 ImGui::Text("%s", format_info.name.c_str());
645
646 if (bitmap.texture()) {
647 ScopedNearestSampling nearest_sampling(ImGui::GetWindowDrawList());
648 ImGui::Image((ImTextureID)(intptr_t)bitmap.texture(),
649 ImVec2(128 * comparison_scale_, 128 * comparison_scale_));
650 }
651
652 ImGui::NextColumn();
653 }
654
655 ImGui::Columns(1);
656}
657
659 ImGui::Text(tr("Format Metrics:"));
660
661 for (auto format : gfx::BppFormatManager::Get().GetAvailableFormats()) {
662 if (!comparison_valid_[format])
663 continue;
664
665 const auto& format_info =
667 std::string metrics = CalculateMetrics(format);
668
669 ImGui::Text("%s: %s", format_info.name.c_str(), metrics.c_str());
670 }
671}
672
674 ImGui::Text(tr("Selected for Analysis: "));
675 ImGui::SameLine();
676
677 const char* format_names[] = {"2BPP", "3BPP", "4BPP", "8BPP"};
678 int selection = static_cast<int>(selected_comparison_) - 2;
679
680 if (ImGui::Combo("##SelectedFormat", &selection, format_names, 4)) {
681 selected_comparison_ = static_cast<gfx::BppFormat>(selection + 2);
682 }
683
684 ImGui::SameLine();
685 ImGui::Checkbox(tr("Show Metrics"), &show_metrics_);
686}
687
689 const auto& format_info = gfx::BppFormatManager::Get().GetFormatInfo(format);
690 int bytes = (source_bitmap_.width() * source_bitmap_.height() *
691 format_info.bits_per_pixel) /
692 8;
693
694 std::ostringstream metrics;
695 metrics << bytes << " bytes, " << format_info.max_colors << " colors";
696
697 return metrics.str();
698}
699
700} // namespace gui
701} // namespace yaze
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:70
TextureHandle texture() const
Definition bitmap.h:410
const std::vector< uint8_t > & vector() const
Definition bitmap.h:411
int height() const
Definition bitmap.h:399
int width() const
Definition bitmap.h:398
int depth() const
Definition bitmap.h:400
BppFormat DetectFormat(const std::vector< uint8_t > &data, int width, int height)
Detect BPP format from bitmap data.
std::vector< BppFormat > GetAvailableFormats() const
Get all available BPP formats.
GraphicsSheetAnalysis AnalyzeGraphicsSheet(const std::vector< uint8_t > &sheet_data, int sheet_id, const SnesPalette &palette)
Analyze graphics sheet to determine original and current BPP formats.
std::vector< uint8_t > ConvertFormat(const std::vector< uint8_t > &data, BppFormat from_format, BppFormat to_format, int width, int height)
Convert bitmap data between BPP formats.
static BppFormatManager & Get()
const BppFormatInfo & GetFormatInfo(BppFormat format) const
Get BPP format information.
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
gfx::BppFormat selected_comparison_
std::string CalculateMetrics(gfx::BppFormat format) const
std::unordered_map< gfx::BppFormat, gfx::Bitmap > comparison_bitmaps_
gfx::SnesPalette source_palette_
void Render()
Render the comparison tool.
void SetSource(const gfx::Bitmap &bitmap, const gfx::SnesPalette &palette)
Set source bitmap for comparison.
std::unordered_map< gfx::BppFormat, gfx::SnesPalette > comparison_palettes_
std::unordered_map< gfx::BppFormat, bool > comparison_valid_
BppComparisonTool(const std::string &id)
Constructor.
std::function< void(gfx::BppFormat, bool)> convert_callback_
BppConversionDialog(const std::string &id)
Constructor.
bool Render()
Render the dialog.
void Show(const gfx::Bitmap &bitmap, const gfx::SnesPalette &palette, std::function< void(gfx::BppFormat, bool)> on_convert)
Show the conversion dialog.
bool RenderFormatSelector(gfx::Bitmap *bitmap, const gfx::SnesPalette &palette, std::function< void(gfx::BppFormat)> on_format_changed)
Render the BPP format selection UI.
void RenderAnalysisPanel(const gfx::Bitmap &bitmap, const gfx::SnesPalette &palette)
Render format analysis panel.
int GetConversionEfficiency(gfx::BppFormat from_format, gfx::BppFormat to_format) const
Get conversion efficiency score.
void RenderSheetAnalysis(const std::vector< uint8_t > &sheet_data, int sheet_id, const gfx::SnesPalette &palette)
Render graphics sheet analysis.
BppFormatUI(const std::string &id)
Constructor.
ImVec4 GetFormatColor(gfx::BppFormat format) const
std::string GetFormatDescription(gfx::BppFormat format) const
std::string last_analysis_sheet_
bool IsConversionAvailable(gfx::BppFormat from_format, gfx::BppFormat to_format) const
Check if format conversion is available.
void RenderConversionHistory(const std::string &history)
void RenderFormatInfo(const gfx::BppFormatInfo &info)
void UpdateAnalysisCache(int sheet_id, const gfx::GraphicsSheetAnalysis &analysis)
std::unordered_map< int, gfx::GraphicsSheetAnalysis > cached_analysis_
void RenderConversionPreview(const gfx::Bitmap &bitmap, gfx::BppFormat target_format, const gfx::SnesPalette &palette)
Render conversion preview.
gfx::BppFormat preview_format_
gfx::BppFormat selected_format_
void RenderColorUsageChart(const std::vector< int > &color_usage)
RAII scope that samples the images drawn inside it with nearest-neighbor filtering.
BppFormat
BPP format enumeration for SNES graphics.
@ kBpp4
4 bits per pixel (16 colors)
@ kBpp3
3 bits per pixel (8 colors)
@ kBpp2
2 bits per pixel (4 colors)
@ kBpp8
8 bits per pixel (256 colors)
ImVec4 GetSuccessColor()
Definition ui_helpers.cc:49
ImVec4 GetErrorColor()
Definition ui_helpers.cc:59
ImVec4 GetWarningColor()
Definition ui_helpers.cc:54
BPP format metadata and conversion information.
Graphics sheet analysis result.