This function draws a JPG image on the display.

Syntax

int ShowJPG(
  int x_offs,
  int y_offs,
  unsigned short mode,
  unsigned char *picture
);

Parameters

x_offs
[in] The horizontal start position of the picture.
y_offs
[in] The vertical start position of the picture.
mode
[in] This can be:
ValueDescription
WRITE_TO_SCREEN The pixels in the supplied buffer are simply drawn on the screen.
The buffer holds 3 bytes per pixel, the LSB is the value for red, the MSB for blue.
TRANSPARENT Same as WRITE_TO_SCREEN, with one important difference.
When a pixel is completely black, it is not written, so then the original pixel is still shown.
picture
[in] A pointer to the JPG image in memory.

Return value

Returns the success (OK) or failure (ERROR) of the function.

Remarks

This function uses the dot coordinates of the screen for drawing.
The values that can be set are as follows.
X (Left and Right): 0 ~ (DISP_WIDTH -1)
Y (Up and Down): 0 ~ (DISP_HEIGHT --1)
When the status bar is displayed, the Y coordinate values that can be set are as follows.
Y (Up and Down)): 0 〜 (DISP_HEIGHT - 17)
ValueDescription
DISP_WIDTH 128 pixel
DISP_HEIGHT 160 pixel

Requirements

Header file:
lib.h
Library file:
libSTARTUPOPH5000.a

Sample

#include <stdio.h>
#include <stdlib.h>
#include "lib.h"

void main(void)
{
    struct ffblk ffblkSt;
    unsigned char *imageBuffer;
    FILE *fp;
    printf("[ShowJPG]\n");
    printf("Please any key\r");
    ResetKey();
    while(!kbhit())
        Idle();
    if (findfirst("image.jpg", &ffblkSt) == OK)
    {
        if ((imageBuffer = malloc(ffblkSt.filesize)) == NULL)
            return;
        fp = fopen("image.jpg","rb");
        if (fp != NULL)
        {
            fread(imageBuffer, ffblkSt.filesize, 1, fp);
            fclose(fp);
        }
        ShowJPG(0, 0, WRITE_TO_SCREEN, imageBuffer);
        printf("Please any key\r");
        ResetKey();
        while(!kbhit())
            Idle();
    }
}

Last updated: 2020/10/02