Public Access
Storage: view pictures, PNG, JPEG, BMP and GIF (#45)
Enter on a picture shows it: shrunk to fit the screen, or at its own size with Enter again and the arrows to move. Dithered to the screen's 256 colours; a colour the screen has exactly is left alone, so screenshots are shown as they are. The picture is decoded once, straight into the screen's buffer, and kept there (App::retainsContent): no copy in memory. Decoding runs on the storage task, so the keys keep working and a 12 megapixel photograph appears as it comes instead of tripping the watchdog. PNG, BMP and GIF are read by decoders of our own, host-tested against files made by Pillow; the PNG one needs 32 KB where the display library's needed 44 KB in one block, which the device often doesn't have. JPEG uses the library's TJpgDec. Also corrects two sentences that still gave 16 KB as the editing limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "apps/image_pane.h"
|
||||
#include "dialog_model.h"
|
||||
#include "key_help.h"
|
||||
#include "key_event.h"
|
||||
@@ -23,7 +24,7 @@ namespace roro {
|
||||
// genuine. Tab switches to the text or the hex of the same file. Nothing here changes a file.
|
||||
class FileViewer {
|
||||
public:
|
||||
FileViewer(StorageService& storage, UpdateService& update) : storage_(storage), update_(update) {}
|
||||
FileViewer(StorageService& storage, UpdateService& update) : storage_(storage), update_(update), image_(storage) {}
|
||||
|
||||
void open(const std::string& path, uint32_t size);
|
||||
void close();
|
||||
@@ -37,9 +38,12 @@ class FileViewer {
|
||||
const std::string& path() const { return path_; }
|
||||
uint32_t size() const { return size_; }
|
||||
void say(const std::string& text);
|
||||
// A picture is drawn once and kept on the screen (App::retainsContent).
|
||||
bool retains() const { return mode_ == Mode::Image; }
|
||||
void lost() { image_.lost(); }
|
||||
|
||||
private:
|
||||
enum class Mode { Text, Hex, Gpx, Pcap, Packet, Ota };
|
||||
enum class Mode { Text, Hex, Gpx, Pcap, Packet, Ota, Image };
|
||||
static constexpr int kRows = 8;
|
||||
static constexpr int kCols = 38;
|
||||
struct Scan; // what a storage job reads through a whole file for: shared with that job
|
||||
@@ -54,6 +58,7 @@ class FileViewer {
|
||||
|
||||
StorageService& storage_;
|
||||
UpdateService& update_;
|
||||
ImagePane image_;
|
||||
std::string path_;
|
||||
uint32_t size_ = 0;
|
||||
Mode mode_ = Mode::Text, base_ = Mode::Text;
|
||||
|
||||
Reference in New Issue
Block a user