aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gdisp/QImage/gdisp_lld_qimage.cpp
blob: f43ba8502b90a4e3c7a7d38de81135fe799d043f (plain)
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
36
37
38
#include <QImage>
#include "../../../gfx.h"
#include "../../../src/gdisp/gdisp_driver.h"
#include "gdisp_lld_qimage.h"

gBool qimage_init(GDisplay* g, gCoord width, gCoord height)
{
    QImage* qimage = new QImage(width, height, QImage::Format_RGB888);
    if (!qimage) {
        return gFalse;
    }
    qimage->fill(Qt::gray);

    g->priv = qimage;

    return gTrue;
}

void qimage_setPixel(GDisplay* g)
{
    QImage* qimage = static_cast<QImage*>(g->priv);
    if (!qimage) {
        return;
    }

    QRgb rgbVal = qRgb(RED_OF(g->p.color), GREEN_OF(g->p.color), BLUE_OF(g->p.color));
    qimage->setPixel(g->p.x, g->p.y, rgbVal);
}

gColor qimage_getPixel(GDisplay* g)
{
    const QImage* qimage = static_cast<const QImage*>(g->priv);
    if (!qimage) {
        return 0;
    }

    return static_cast<gColor>(qimage->pixel(g->p.x, g->p.y));
}