This function draws a BMP image on the display.

Syntax

void ShowBMP(
  int x_offs,
  int y_offs,
  unsigned short mode,
  unsigned char *bmp
);

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.
bmp
[in] A pointer to the BMP image in memory.

Return value

None

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("[ShowBMP]\n");
    printf("Please any key\r");
    ResetKey();
    while(!kbhit())
        Idle();
    if (findfirst("image.bmp", &ffblkSt) == OK)
    {
        if ((imageBuffer = malloc(ffblkSt.filesize)) == NULL)
            return;
        fp = fopen("image.bmp","rb");
        if (fp != NULL)
        {
            fread(imageBuffer, ffblkSt.filesize, 1, fp);
            fclose(fp);
        }
        ShowBMP(0, 0, WRITE_TO_SCREEN, imageBuffer);
        printf("Please any key\r");
        ResetKey();
        while(!kbhit())
            Idle();
    }
}

Last updated: 2020/10/02