ugfx/drivers/gdisp/QImage/gdisp_lld_qimage.cpp

39 lines
851 B
C++
Raw Permalink Normal View History

2016-07-18 23:24:05 +00:00
#include <QImage>
#include "../../../gfx.h"
#include "../../../src/gdisp/gdisp_driver.h"
#include "gdisp_lld_qimage.h"
2018-07-08 00:54:19 +00:00
gBool qimage_init(GDisplay* g, gCoord width, gCoord height)
2016-07-18 23:24:05 +00:00
{
QImage* qimage = new QImage(width, height, QImage::Format_RGB888);
if (!qimage) {
return gFalse;
2016-07-18 23:24:05 +00:00
}
qimage->fill(Qt::gray);
g->priv = qimage;
return gTrue;
2016-07-18 23:24:05 +00:00
}
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);
}
2018-07-08 01:19:43 +00:00
gColor qimage_getPixel(GDisplay* g)
2016-07-18 23:24:05 +00:00
{
const QImage* qimage = static_cast<const QImage*>(g->priv);
if (!qimage) {
return 0;
}
2018-07-08 01:19:43 +00:00
return static_cast<gColor>(qimage->pixel(g->p.x, g->p.y));
2016-07-18 23:24:05 +00:00
}