52 const char rgbStr[] =
"RGB";
53 const char rgbaStr[] =
"RGBA";
54 const char unknownStr[] =
"???";
55 const char* channelStr;
57 surface_t image = surface_make_linear(
64 rdpq_attach(disp, NULL);
66 rdpq_set_mode_fill(RGBA32(0, 0, 0, 255));
67 rdpq_fill_rectangle(0, 0, 320, 240);
69 rdpq_set_mode_standard();
72 rdpq_tex_blit(&image, 0.0, 0.0, NULL);
81 channelStr = unknownStr;
93 "N64 QOI Viewer (Revised: %s)\n"
98 QOI_DEC_REVISION_DATE,
122 int seek = 0, buffer_size;
123 long long start, end;
137 start = timer_ticks();
138 fp = fopen(filename,
"rb");
145 fseek(fp, 0, SEEK_END);
146 buffer_size = ftell(fp);
147 fseek(fp, 0, SEEK_SET);
149 qoi_bytes = (uint8_t*)malloc(buffer_size *
sizeof(uint8_t));
153 fread(qoi_bytes, 1, buffer_size, fp);
159 qoi_desc_init(&desc);
161 if (!read_qoi_header(&desc, qoi_bytes)) {
166 info->
width = desc.width;
167 info->
height = desc.height;
172 "%s is too big to open and read\n\
173 To prevent buffer overrun on big sized QOI images,\n\
174 QOI Viewer has been terminated.\n\
175 Make sure your QOI image is a maximum of 320 pixels\n\
176 in width and 240 pixels in height",
184 .img_area = desc.width * desc.height,
185 .qoi_len = buffer_size,
187 .offset = qoi_bytes + 14
191 for (uint8_t element = 0; element < 64; element++)
192 qoi_initalize_pixel(&dec.buffer[element]);
194 qoi_set_pixel_rgba(&dec.prev_pixel, 0, 0, 0, 255);
196 while (!qoi_dec_done(&dec)) {
197 px = qoi_decode_chunk(&dec);
201 *(uint32_t*)(bytes+seek) = px.concatenated_pixel_values;
207 sys_hw_memset(info->
name, 0, 256);
210 memcpy(info->
name, filename, strlen(filename) < 256 ? strlen(filename) : 255);
217 info->
decodeTime = (float)((
float)(end - start) / (
float)TICKS_PER_SECOND);
uint8_t buffer0[IMG_BUFFER_SIZE]
Raw image buffer that decoded from qoi image file.
void openQOIFile(const char *filename, uint8_t *bytes, qoi_img_info_t *info)
This function decodes QOI file from from into the framebuffer.