Rather than going to the filesystem to save and read back a PGM image file, I want to do this in memory. Can I somehow use a QBuffer as an in memory QFile to bypass saving to the filesystem:
QFile filename(QString("/home/pi/frame-%1.pgm").arg(i));
bool didOpen = filename.open(QIODevice::ReadWrite);
qDebug() << "Did open file: " << didOpen << filename.fileName();
int fileHandle = filename.handle();
FILE * f = fdopen(dup(fileHandle), "wb");
int res = fprintf(f, "P5 %d %d 65535\n", w, h);
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
uint16_t v = img[y*w+x];
//v = htobe16(v);
res = fwrite((uint8_t*)&v, sizeof(uint16_t), 1, f);
}
}
fclose(f);
QPixmap pixmap;
bool didLoad = pixmap.load(QString("/home/pi/frame-%1.pgm").arg(i));
emit updateScreen(pixmap);