Numworks Epsilon  1.4.1
Graphing Calculator Operating System
fltklcd.cpp
Go to the documentation of this file.
1 #include "fltklcd.h"
2 #include <stdlib.h>
3 #include <FL/fl_draw.H>
4 
5 FltkLCD::FltkLCD(int x, int y, int w, int h, KDColor * rgb565FrameBuffer) :
6  Fl_Widget(x, y, w, h, nullptr),
7  m_rgb565frameBufferStart(rgb565FrameBuffer),
8  m_rgb565frameBufferEnd(rgb565FrameBuffer+w*h)
9 {
10  m_rgb888frameBufferStart = malloc(w*h*3);
11 }
12 
14  free(m_rgb888frameBufferStart);
15 }
16 
17 void FltkLCD::draw() {
18  // 1/ Convert the framebuffer from 565 to 888
19  KDColor * rgb565Pixel = m_rgb565frameBufferStart;
20  uint8_t * rgb888Component = (uint8_t *)m_rgb888frameBufferStart;
21 
22  while(rgb565Pixel < m_rgb565frameBufferEnd) {
23  KDColor color = *rgb565Pixel++;
24  *rgb888Component++ = color.red();
25  *rgb888Component++ = color.green();
26  *rgb888Component++ = color.blue();
27  }
28 
29  // 2/ Draw the 888 framebuffer
30  fl_draw_image((const uchar *)m_rgb888frameBufferStart,
31  x(), // x
32  y(), // y
33  w(), // width
34  h()); // height);
35 }
LIBA_BEGIN_DECLS void free(void *ptr)
Definition: malloc.c:33
unsigned char uint8_t
Definition: stdint.h:4
void draw()
Definition: fltklcd.cpp:17
uint8_t green() const
Definition: color.h:24
uint8_t red() const
Definition: color.h:19
void * malloc(size_t size)
Definition: malloc.c:44
~FltkLCD()
Definition: fltklcd.cpp:13
Definition: color.h:6
uint8_t blue() const
Definition: color.h:29
FltkLCD(int x, int y, int w, int h, KDColor *rgb565FrameBuffer)
Definition: fltklcd.cpp:5