Blame view

build3/ion/src/simulator/display/fltklcd.cpp 944 Bytes
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  #include "fltklcd.h"
  #include <stdlib.h>
  #include <FL/fl_draw.H>
  
  FltkLCD::FltkLCD(int x, int y, int w, int h, KDColor * rgb565FrameBuffer) :
    Fl_Widget(x, y, w, h, nullptr),
    m_rgb565frameBufferStart(rgb565FrameBuffer),
    m_rgb565frameBufferEnd(rgb565FrameBuffer+w*h)
  {
    m_rgb888frameBufferStart = malloc(w*h*3);
  }
  
  FltkLCD::~FltkLCD() {
    free(m_rgb888frameBufferStart);
  }
  
  void FltkLCD::draw() {
    // 1/ Convert the framebuffer from 565 to 888
    KDColor * rgb565Pixel = m_rgb565frameBufferStart;
    uint8_t * rgb888Component = (uint8_t *)m_rgb888frameBufferStart;
  
    while(rgb565Pixel < m_rgb565frameBufferEnd) {
      KDColor color = *rgb565Pixel++;
      *rgb888Component++ = color.red();
      *rgb888Component++ = color.green();
      *rgb888Component++ = color.blue();
    }
  
    // 2/ Draw the 888 framebuffer
    fl_draw_image((const uchar *)m_rgb888frameBufferStart,
        x(), // x
        y(), // y
        w(), // width
        h()); // height);
  }