fix file-based screenshot methods for HD
This commit is contained in:
parent
8c00e2c676
commit
f36f5b5627
|
@ -427,12 +427,10 @@ static int WritePNGChunk(FILE *fp, uint32 size, const char *type, const uint8 *d
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NDS_WritePNG(const char *fname, u16 *data)
|
int NDS_WritePNG_16bpp(int width, int height, const u16 *data, const char *fname)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
int width=256;
|
const u16 * bmp = data;
|
||||||
int height=192*2;
|
|
||||||
u16 * bmp = data;
|
|
||||||
FILE *pp=NULL;
|
FILE *pp=NULL;
|
||||||
uint8 *compmem = NULL;
|
uint8 *compmem = NULL;
|
||||||
uLongf compmemsize = (uLongf)( (height * (width + 1) * 3 * 1.001 + 1) + 12 );
|
uLongf compmemsize = (uLongf)( (height * (width + 1) * 3 * 1.001 + 1) + 12 );
|
||||||
|
@ -485,7 +483,7 @@ int NDS_WritePNG(const char *fname, u16 *data)
|
||||||
for(x=0;x<width;x++)
|
for(x=0;x<width;x++)
|
||||||
{
|
{
|
||||||
int r,g,b;
|
int r,g,b;
|
||||||
u16 pixel = bmp[y*256+x];
|
u16 pixel = bmp[y*width+x];
|
||||||
r = pixel>>10;
|
r = pixel>>10;
|
||||||
pixel-=r<<10;
|
pixel-=r<<10;
|
||||||
g = pixel>>5;
|
g = pixel>>5;
|
||||||
|
@ -552,13 +550,13 @@ typedef struct
|
||||||
} bmpfileheader_struct;
|
} bmpfileheader_struct;
|
||||||
#include "PACKED_END.h"
|
#include "PACKED_END.h"
|
||||||
|
|
||||||
int NDS_WriteBMP(const char *filename, u16 *data)
|
int NDS_WriteBMP_16bpp(int width, int height, const u16 *data, const char *filename)
|
||||||
{
|
{
|
||||||
bmpfileheader_struct fileheader;
|
bmpfileheader_struct fileheader;
|
||||||
bmpimgheader_struct imageheader;
|
bmpimgheader_struct imageheader;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int i,j;
|
int i,j;
|
||||||
u16 * bmp = data;
|
const u16 * bmp = data;
|
||||||
size_t elems_written = 0;
|
size_t elems_written = 0;
|
||||||
|
|
||||||
memset(&fileheader, 0, sizeof(fileheader));
|
memset(&fileheader, 0, sizeof(fileheader));
|
||||||
|
@ -568,8 +566,8 @@ int NDS_WriteBMP(const char *filename, u16 *data)
|
||||||
|
|
||||||
memset(&imageheader, 0, sizeof(imageheader));
|
memset(&imageheader, 0, sizeof(imageheader));
|
||||||
imageheader.size = sizeof(imageheader);
|
imageheader.size = sizeof(imageheader);
|
||||||
imageheader.width = 256;
|
imageheader.width = width;
|
||||||
imageheader.height = 192*2;
|
imageheader.height = height;
|
||||||
imageheader.planes = 1;
|
imageheader.planes = 1;
|
||||||
imageheader.bpp = 24;
|
imageheader.bpp = 24;
|
||||||
imageheader.cmptype = 0; // None
|
imageheader.cmptype = 0; // None
|
||||||
|
@ -581,12 +579,12 @@ int NDS_WriteBMP(const char *filename, u16 *data)
|
||||||
elems_written += fwrite(&fileheader, 1, sizeof(fileheader), file);
|
elems_written += fwrite(&fileheader, 1, sizeof(fileheader), file);
|
||||||
elems_written += fwrite(&imageheader, 1, sizeof(imageheader), file);
|
elems_written += fwrite(&imageheader, 1, sizeof(imageheader), file);
|
||||||
|
|
||||||
for(j=0;j<192*2;j++)
|
for(j=0;j<height;j++)
|
||||||
{
|
{
|
||||||
for(i=0;i<256;i++)
|
for(i=0;i<width;i++)
|
||||||
{
|
{
|
||||||
u8 r,g,b;
|
u8 r,g,b;
|
||||||
u16 pixel = bmp[(192*2-j-1)*256+i];
|
u16 pixel = bmp[(height-j-1)*width+i];
|
||||||
r = pixel>>10;
|
r = pixel>>10;
|
||||||
pixel-=r<<10;
|
pixel-=r<<10;
|
||||||
g = pixel>>5;
|
g = pixel>>5;
|
||||||
|
|
|
@ -87,9 +87,9 @@ struct MAKER
|
||||||
std::string getDeveloperNameByID(u16 id);
|
std::string getDeveloperNameByID(u16 id);
|
||||||
|
|
||||||
|
|
||||||
extern int NDS_WritePNG(const char *fname, u16 *data);
|
int NDS_WritePNG_16bpp(int width, int height, const u16 *data, const char *fname);
|
||||||
extern int NDS_WriteBMP(const char *filename, u16 *data);
|
int NDS_WriteBMP_16bpp(int width, int height, const u16 *data, const char *filename);
|
||||||
extern int NDS_WriteBMP_32bppBuffer(int width, int height, const void* buf, const char *filename);
|
int NDS_WriteBMP_32bppBuffer(int width, int height, const void* buf, const char *filename);
|
||||||
|
|
||||||
void* malloc_aligned(size_t length, size_t alignment);
|
void* malloc_aligned(size_t length, size_t alignment);
|
||||||
void* malloc_aligned16(size_t length);
|
void* malloc_aligned16(size_t length);
|
||||||
|
|
|
@ -145,30 +145,30 @@ void HK_QuickScreenShot(int param, bool justPressed)
|
||||||
if(!romloaded) return;
|
if(!romloaded) return;
|
||||||
if(!justPressed) return;
|
if(!justPressed) return;
|
||||||
|
|
||||||
char buffer[MAX_PATH];
|
char fname[MAX_PATH];
|
||||||
ZeroMemory(buffer, sizeof(buffer));
|
ZeroMemory(fname, sizeof(fname));
|
||||||
path.getpath(path.SCREENSHOTS, buffer);
|
path.getpath(path.SCREENSHOTS, fname);
|
||||||
|
|
||||||
char file[MAX_PATH];
|
char file[MAX_PATH];
|
||||||
ZeroMemory(file, sizeof(file));
|
ZeroMemory(file, sizeof(file));
|
||||||
path.formatname(file);
|
path.formatname(file);
|
||||||
|
|
||||||
strcat(buffer, file);
|
strcat(fname, file);
|
||||||
if( strlen(buffer) > (MAX_PATH - 4))
|
if( strlen(fname) > (MAX_PATH - 4))
|
||||||
buffer[MAX_PATH - 4] = '\0';
|
fname[MAX_PATH - 4] = '\0';
|
||||||
|
|
||||||
switch(path.imageformat())
|
switch(path.imageformat())
|
||||||
{
|
{
|
||||||
case path.PNG:
|
case path.PNG:
|
||||||
{
|
{
|
||||||
strcat(buffer, ".png");
|
strcat(fname, ".png");
|
||||||
NDS_WritePNG(buffer, GPU->GetNativeFramebuffer());
|
NDS_WritePNG_16bpp(GPU->GetCustomFramebufferWidth(), GPU->GetCustomFramebufferHeight()*2, GPU->GetCustomFramebuffer(), fname);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case path.BMP:
|
case path.BMP:
|
||||||
{
|
{
|
||||||
strcat(buffer, ".bmp");
|
strcat(fname, ".bmp");
|
||||||
NDS_WriteBMP(buffer, GPU->GetNativeFramebuffer());
|
NDS_WriteBMP_16bpp(GPU->GetCustomFramebufferWidth(), GPU->GetCustomFramebufferHeight()*2, GPU->GetCustomFramebuffer(), fname);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -220,9 +220,9 @@ void HK_PrintScreen(int param, bool justPressed)
|
||||||
filename = outFilename;
|
filename = outFilename;
|
||||||
|
|
||||||
if(toupper(strright(filename,4)) == ".PNG")
|
if(toupper(strright(filename,4)) == ".PNG")
|
||||||
NDS_WritePNG(filename.c_str(), GPU->GetNativeFramebuffer());
|
NDS_WritePNG_16bpp(GPU->GetCustomFramebufferWidth(), GPU->GetCustomFramebufferHeight()*2, GPU->GetNativeFramebuffer(), filename.c_str());
|
||||||
else if(toupper(strright(filename,4)) == ".BMP")
|
else if(toupper(strright(filename,4)) == ".BMP")
|
||||||
NDS_WriteBMP(filename.c_str(), GPU->GetNativeFramebuffer());
|
NDS_WriteBMP_16bpp(GPU->GetCustomFramebufferWidth(), GPU->GetCustomFramebufferHeight()*2, GPU->GetNativeFramebuffer(), filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unpause) NDS_UnPause(false);
|
if(unpause) NDS_UnPause(false);
|
||||||
|
|
Loading…
Reference in New Issue