portapack-mayhem / mayhem-firmware

Custom firmware for the HackRF+PortaPack H1/H2
GNU General Public License v3.0
3.02k stars 518 forks source link

Bmp File Viewer + extras #2119

Closed htotoo closed 2 months ago

htotoo commented 2 months ago

This is a big pr, trying to get all the changes, with some documentation.

Got a new View BMPFileViewer. You pass a path to it and it tries to open the BMP file. It goes to full screen mode, and can exit via "enter" key on the keypad. You can use most features of the new Widget in this app, described bellow.

This View won't replace splashviewer (could, but need to handle the exit part and show a popup if want to set up the splash screen, if the resolution is ok, ... not done this.)

Fileman is modified, so it'll look for the BMP extension. If a BMP file is opened, checks the dir. From the SPLASH dir, it opens the splashviewer, otherwise it opens the new BMPFV app.

File.cpp got 2 new functions, close(), and eof(). This way I can reuse the same BMP object, and open a new file, ...

BMPViewer is a new Widget. This can load a BMP file and can zoom, and scroll in it. Default to 'enter' key, is to fit zoom, and scroll to 0,0 position. (enter key can be overrided to pass it to parent). This widget can be any size, and in theory it can handle any size (uint32 x, int32 y) bmp image. (see BMPFile class).

SystemView got a new function set_app_fullscreen(). With this, you can hide / show the status bar. (Don't forget to set it back when you don't need it!)

UsbSerialAsyncmsg::asyncmsg got a float overload.

firmware/common/bmp.hpp got a breaking change! The height of the image can be negative, and this indicates the bottom-up parameter for viewers. ( see https://en.wikipedia.org/wiki/BMP_file_format )

BMPFile class. With this class, you can open a BMP file, and manipulate it. Or create a new file. Need to mention, the create function is yet limited to top-to bottom format, and 3 byte color depth. The image then can be expanded by Y axe. With this, you can receive APT, FAX, ... without knowing how long will be the RX. You must use SEEK() function. The BMP width and height parameter is the number of pixels, but the seek(x,y) coordinates are 0 based. so can seek 0 --> (width-1), 0--> (height-1) px. read_next_px() reades the pixel and advances to the next if it is not disabled. write_next_px() also can be called multiple times, and writes px next to each other. But if you use the bottom-up format, don't forget to seek to the right y coordinate after each line. If you don't set background, the file will contain garbage where there was no px written, but the creation and expansion will be much faster. Won't load BMP files that has color table (<=8bit, ..). No memory to store and calculate that. Also constant seeking would slow down the process much.