N64 QOI Demo
A N64 homebrew app that opens QOI images from ROM
Loading...
Searching...
No Matches
qoi_viewer.h
Go to the documentation of this file.
1/*
2
3 qoi_viewer.h
4
5 This header contains declaration of functions related to QOI viewer
6
7 Code licensed under MIT License
8
9 Copyright (c) 2025 Aftersol
10
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in all
19 copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 SOFTWARE.
28
29*/
32
33#ifndef QOI_VIEWER_H
34#define QOI_VIEWER_H
35
36#if __cplusplus
37extern "C" {
38#endif
39
40#include "sQOI.h"
41#include <stdint.h>
42#include <stdbool.h>
43#include <libdragon.h>
44
46#define IMG_BUFFER_SIZE 307200
47
48extern uint8_t buffer0[IMG_BUFFER_SIZE];
49
50extern uint8_t buffer1[IMG_BUFFER_SIZE];
51
67
69typedef struct qoi_img_info {
71 int width;
72
74 int height;
75
78
81
84
86 char name[256];
87
91
95void draw_image(surface_t* disp, qoi_img_info_t info);
96
101void openQOIFile(const char* filename, uint8_t* bytes, qoi_img_info_t* info);
102
105inline void toggleDebugText(qoi_img_info_t* info) {
106 info->renderDebugFont ^= true;
107}
108
109#if __cplusplus
110}
111#endif
112
113#endif // QOI_VIEWER_H
uint8_t buffer1[IMG_BUFFER_SIZE]
second raw image buffer that decoded from qoi image file
Definition main.c:57
uint8_t buffer0[IMG_BUFFER_SIZE]
Raw image buffer that decoded from qoi image file.
Definition main.c:54
void toggleDebugText(qoi_img_info_t *info)
Toggles printing debugging text.
Definition qoi_viewer.h:105
void draw_image(surface_t *disp, qoi_img_info_t info)
This function draws image decoded from QOI.
Definition qoi_viewer.c:50
qoi_error_code
Error codes for different situations when handling a QOI file.
Definition qoi_viewer.h:53
@ QOI_NOT_INITIALIZED
QOI Image not yet decoded.
Definition qoi_viewer.h:55
@ QOI_OK
QOI Image decoded successfully.
Definition qoi_viewer.h:57
@ QOI_INVAILD_FILE
Invaild QOI image file found.
Definition qoi_viewer.h:61
@ QOI_NO_FILENAME
Filename to the QOI image not passed to decoder.
Definition qoi_viewer.h:65
@ QOI_NO_FILE
No file found given a filename to the supposed QOI image.
Definition qoi_viewer.h:63
@ QOI_NULL_BUFFER
No buffer for image found.
Definition qoi_viewer.h:59
void openQOIFile(const char *filename, uint8_t *bytes, qoi_img_info_t *info)
This function decodes QOI file from from into the framebuffer.
Definition qoi_viewer.c:110
struct qoi_img_info qoi_img_info_t
Metadata about the QOI image and the QOI image viewer.
#define IMG_BUFFER_SIZE
Image buffer size: 320 pixels in width * 240 pixels in height * 4 channels.
Definition qoi_viewer.h:46
Metadata about the QOI image and the QOI image viewer.
Definition qoi_viewer.h:69
int channels
Number of channels of the QOI image where 3 is RGB and 4 is RGBA.
Definition qoi_viewer.h:77
char name[256]
Names of QOI file.
Definition qoi_viewer.h:86
int height
Height of the QOI image.
Definition qoi_viewer.h:74
float decodeTime
Decoding time in seconds.
Definition qoi_viewer.h:83
int width
Width of the QOI image.
Definition qoi_viewer.h:71
bool renderDebugFont
Whether to toggle displaying debug text upon pressing the Start button on the N64 controller.
Definition qoi_viewer.h:89
qoi_error_code error
Error code as the result of decoding.
Definition qoi_viewer.h:80