mirror of https://github.com/mgba-emu/mgba.git
Core: Add mCoreTakeScreenshotVF function
This commit is contained in:
parent
fe10c00289
commit
f3c26add07
|
@ -187,6 +187,7 @@ struct VFile* mCoreGetState(struct mCore* core, int slot, bool write);
|
|||
void mCoreDeleteState(struct mCore* core, int slot);
|
||||
|
||||
void mCoreTakeScreenshot(struct mCore* core);
|
||||
bool mCoreTakeScreenshotVF(struct mCore* core, struct VFile* vf);
|
||||
#endif
|
||||
|
||||
struct mCore* mCoreFindVF(struct VFile* vf);
|
||||
|
|
|
@ -308,10 +308,6 @@ void mCoreDeleteState(struct mCore* core, int slot) {
|
|||
|
||||
void mCoreTakeScreenshot(struct mCore* core) {
|
||||
#ifdef USE_PNG
|
||||
size_t stride;
|
||||
const void* pixels = 0;
|
||||
unsigned width, height;
|
||||
core->desiredVideoDimensions(core, &width, &height);
|
||||
struct VFile* vf;
|
||||
#ifndef PSP2
|
||||
vf = VDirFindNextAvailable(core->dirs.screenshot, core->dirs.baseName, "-", ".png", O_CREAT | O_TRUNC | O_WRONLY);
|
||||
|
@ -320,11 +316,7 @@ void mCoreTakeScreenshot(struct mCore* core) {
|
|||
#endif
|
||||
bool success = false;
|
||||
if (vf) {
|
||||
core->getPixels(core, &pixels, &stride);
|
||||
png_structp png = PNGWriteOpen(vf);
|
||||
png_infop info = PNGWriteHeader(png, width, height);
|
||||
success = PNGWritePixels(png, width, height, stride, pixels);
|
||||
PNGWriteClose(png, info);
|
||||
success = mCoreTakeScreenshotVF(core, vf);
|
||||
#ifdef PSP2
|
||||
void* data = vf->map(vf, 0, 0);
|
||||
PhotoExportParam param = {
|
||||
|
@ -349,6 +341,23 @@ void mCoreTakeScreenshot(struct mCore* core) {
|
|||
}
|
||||
#endif
|
||||
|
||||
bool mCoreTakeScreenshotVF(struct mCore* core, struct VFile* vf) {
|
||||
#ifdef USE_PNG
|
||||
size_t stride;
|
||||
const void* pixels = 0;
|
||||
unsigned width, height;
|
||||
core->desiredVideoDimensions(core, &width, &height);
|
||||
core->getPixels(core, &pixels, &stride);
|
||||
png_structp png = PNGWriteOpen(vf);
|
||||
png_infop info = PNGWriteHeader(png, width, height);
|
||||
bool success = PNGWritePixels(png, width, height, stride, pixels);
|
||||
PNGWriteClose(png, info);
|
||||
return success;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void mCoreInitConfig(struct mCore* core, const char* port) {
|
||||
mCoreConfigInit(&core->config, port);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue