Possible simple example to display a bitmap image:
http://repository.timesys.com/builds...-omap3530zoom/
Unfortunately it does not work.
I get a black screen in the console / tty
Code:
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/kd.h>
#define IMAGE_INTERVAL 10
#define X 480
#define Y 640
#define BITS_PER_PIXEL 16
#define BITS_PER_BYTE 8
#define SCREEN_SIZE (X * Y * ( BITS_PER_PIXEL / BITS_PER_BYTE ))
void show_bitmap (const char *image_name)
{
int status, image_fd, fb_fd;
unsigned char buffer[SCREEN_SIZE];
fb_fd = open("/dev/fb0", O_RDWR);
if (!fb_fd) {
fprintf(stderr,"Could not open framebuffer.\n");
exit(1);
}
image_fd = open("images/flower.bmp", O_RDONLY);
if (image_fd < 0)
{
fprintf(stderr,"Failed to open image: %s\n", image_name);
exit(1);
}
status = read(image_fd, (char*)buffer, SCREEN_SIZE);
if (status < 0)
{
fprintf(stderr,"Failed to read image: %s\n", image_name);
exit(1);
}
status = write(fb_fd, (const char*)buffer, SCREEN_SIZE);
if (status < 0)
{
fprintf(stderr,"Failed to write image to buffer.\n");
exit(1);
}
close(image_fd);
close(fb_fd);
}
int main (int argc, char *argv[])
{
int index = 1;
int vconsole_fd;
if (argc < 2)
{
printf("Usage: %s [image] [image...]\n", argv[0]);
exit(1);
}
/* open the framebuffer virtual console */
vconsole_fd = open("/dev/tty0", O_RDWR);
if (!vconsole_fd) {
fprintf(stderr,"Could not open virtual console.\n");
exit(1);
}
/* disable blanking on the console by setting the KD_GRAPHICS mode */
if (ioctl( vconsole_fd, KDSETMODE, KD_GRAPHICS))
{
fprintf(stderr,"Could not set virtual console to KD_GRAPHICS mode.\n");
exit(1);
}
close(vconsole_fd);
/* no chdir and no stdio close */
daemon(1,1);
while (1)
{
show_bitmap(argv[index]);
index++;
if (index >= argc)
index = 1;
sleep(IMAGE_INTERVAL);
}
}