Remove JPG and BMP support. Add uPNG support.
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "tftspi.h"
|
||||
#include "upng.h"
|
||||
|
||||
typedef struct {
|
||||
uint16_t x1;
|
||||
@ -601,43 +602,8 @@ void mgos_ili9341_clearStringRect(int x, int y, char *str);
|
||||
//----------------------------------------------------------
|
||||
color_t HSBtoRGB(float _hue, float _sat, float _brightness);
|
||||
|
||||
/*
|
||||
* Decodes and displays JPG image
|
||||
* Limits:
|
||||
* Baseline only. Progressive and Lossless JPEG format are not supported.
|
||||
* Image size: Up to 65520 x 65520 pixels
|
||||
* Color space: YCbCr three components only. Gray scale image is not supported.
|
||||
* Sampling factor: 4:4:4, 4:2:2 or 4:2:0.
|
||||
*
|
||||
* Params:
|
||||
* x: image left position; constants CENTER & RIGHT can be used; negative value is accepted
|
||||
* y: image top position; constants CENTER & BOTTOM can be used; negative value is accepted
|
||||
* scale: image scale factor: 0~3; if scale>0, image is scaled by factor 1/(2^scale) (1/2, 1/4 or 1/8)
|
||||
* fname: pointer to the name of the file from which the image will be read
|
||||
* if set to NULL, image will be read from memory buffer pointed to by 'buf'
|
||||
* buf: pointer to the memory buffer from which the image will be read; used if fname=NULL
|
||||
* size: size of the memory buffer from which the image will be read; used if fname=NULL & buf!=NULL
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------------
|
||||
void mgos_ili9341_jpg_image(int x, int y, uint8_t scale, char *fname, uint8_t *buf, int size);
|
||||
|
||||
/*
|
||||
* Decodes and displays BMP image
|
||||
* Only uncompressed RGB 24-bit with no color space information BMP images can be displayed
|
||||
*
|
||||
* Params:
|
||||
* x: image left position; constants CENTER & RIGHT can be used; negative value is accepted
|
||||
* y: image top position; constants CENTER & BOTTOM can be used; negative value is accepted
|
||||
* scale: image scale factor: 0~7; if scale>0, image is scaled by factor 1/(scale+1)
|
||||
* fname: pointer to the name of the file from which the image will be read
|
||||
* if set to NULL, image will be read from memory buffer pointed to by 'imgbuf'
|
||||
* imgbuf: pointer to the memory buffer from which the image will be read; used if fname=NULL
|
||||
* size: size of the memory buffer from which the image will be read; used if fname=NULL & imgbuf!=NULL
|
||||
*
|
||||
*/
|
||||
//-------------------------------------------------------------------------------------
|
||||
int mgos_ili9341_bmp_image(int x, int y, uint8_t scale, char *fname, uint8_t *imgbuf, int size);
|
||||
/* Draw PNG at coords x,y */
|
||||
int mgos_ili9341_png(int x, int y, char *fname);
|
||||
|
||||
/*
|
||||
* Compile font c source file to .fnt file
|
||||
|
81
libs/ili9341/include/upng.h
Normal file
81
libs/ili9341/include/upng.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
uPNG -- derived from LodePNG version 20100808
|
||||
|
||||
Copyright (c) 2005-2010 Lode Vandevenne
|
||||
Copyright (c) 2010 Sean Middleditch
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#if !defined(UPNG_H)
|
||||
#define UPNG_H
|
||||
|
||||
typedef enum upng_error {
|
||||
UPNG_EOK = 0, /* success (no error) */
|
||||
UPNG_ENOMEM = 1, /* memory allocation failed */
|
||||
UPNG_ENOTFOUND = 2, /* resource not found (file missing) */
|
||||
UPNG_ENOTPNG = 3, /* image data does not have a PNG header */
|
||||
UPNG_EMALFORMED = 4, /* image data is not a valid PNG image */
|
||||
UPNG_EUNSUPPORTED = 5, /* critical PNG chunk type is not supported */
|
||||
UPNG_EUNINTERLACED = 6, /* image interlacing is not supported */
|
||||
UPNG_EUNFORMAT = 7, /* image color format is not supported */
|
||||
UPNG_EPARAM = 8 /* invalid parameter to method call */
|
||||
} upng_error;
|
||||
|
||||
typedef enum upng_format {
|
||||
UPNG_BADFORMAT,
|
||||
UPNG_RGB8,
|
||||
UPNG_RGB16,
|
||||
UPNG_RGBA8,
|
||||
UPNG_RGBA16,
|
||||
UPNG_LUMINANCE1,
|
||||
UPNG_LUMINANCE2,
|
||||
UPNG_LUMINANCE4,
|
||||
UPNG_LUMINANCE8,
|
||||
UPNG_LUMINANCE_ALPHA1,
|
||||
UPNG_LUMINANCE_ALPHA2,
|
||||
UPNG_LUMINANCE_ALPHA4,
|
||||
UPNG_LUMINANCE_ALPHA8
|
||||
} upng_format;
|
||||
|
||||
typedef struct upng_t upng_t;
|
||||
|
||||
upng_t* upng_new_from_bytes (const unsigned char* buffer, unsigned long size);
|
||||
upng_t* upng_new_from_file (const char* path);
|
||||
void upng_free (upng_t* upng);
|
||||
|
||||
upng_error upng_header (upng_t* upng);
|
||||
upng_error upng_decode (upng_t* upng);
|
||||
|
||||
upng_error upng_get_error (const upng_t* upng);
|
||||
unsigned upng_get_error_line (const upng_t* upng);
|
||||
|
||||
unsigned upng_get_width (const upng_t* upng);
|
||||
unsigned upng_get_height (const upng_t* upng);
|
||||
unsigned upng_get_bpp (const upng_t* upng);
|
||||
unsigned upng_get_bitdepth (const upng_t* upng);
|
||||
unsigned upng_get_components (const upng_t* upng);
|
||||
unsigned upng_get_pixelsize (const upng_t* upng);
|
||||
upng_format upng_get_format (const upng_t* upng);
|
||||
|
||||
const unsigned char* upng_get_buffer (const upng_t* upng);
|
||||
unsigned upng_get_size (const upng_t* upng);
|
||||
|
||||
#endif /*defined(UPNG_H)*/
|
Reference in New Issue
Block a user