write 24bpp pngs for screenshots using new deemph code
This commit is contained in:
parent
96078b99ac
commit
57ec344b1f
|
@ -568,7 +568,7 @@ int SaveSnapshot(void)
|
|||
int x,u,y;
|
||||
FILE *pp=NULL;
|
||||
uint8 *compmem=NULL;
|
||||
uLongf compmemsize=totallines*263+12;
|
||||
uLongf compmemsize=(totallines*263+12)*3;
|
||||
|
||||
if(!(compmem=(uint8 *)FCEU_malloc(compmemsize)))
|
||||
return 0;
|
||||
|
@ -588,7 +588,7 @@ int SaveSnapshot(void)
|
|||
}
|
||||
|
||||
{
|
||||
static uint8 header[8]={137,80,78,71,13,10,26,10};
|
||||
static const uint8 header[8]={137,80,78,71,13,10,26,10};
|
||||
if(fwrite(header,8,1,pp)!=1)
|
||||
goto PNGerr;
|
||||
}
|
||||
|
@ -602,8 +602,8 @@ int SaveSnapshot(void)
|
|||
chunko[4]=chunko[5]=chunko[6]=0;
|
||||
chunko[7]=totallines; // Height
|
||||
|
||||
chunko[8]=8; // bit depth
|
||||
chunko[9]=3; // Color type; indexed 8-bit
|
||||
chunko[8]=8; // 8 bits per sample(24 bits per pixel)
|
||||
chunko[9]=2; // Color type; RGB triplet
|
||||
chunko[10]=0; // compression: deflate
|
||||
chunko[11]=0; // Basic adapative filter set(though none are used).
|
||||
chunko[12]=0; // No interlace.
|
||||
|
@ -612,19 +612,12 @@ int SaveSnapshot(void)
|
|||
goto PNGerr;
|
||||
}
|
||||
|
||||
{
|
||||
uint8 pdata[256*3];
|
||||
for(x=0;x<256;x++)
|
||||
FCEUD_GetPalette(x,pdata+x*3,pdata+x*3+1,pdata+x*3+2);
|
||||
if(!WritePNGChunk(pp,256*3,"PLTE",pdata))
|
||||
goto PNGerr;
|
||||
}
|
||||
|
||||
{
|
||||
uint8 *tmp=XBuf+FSettings.FirstSLine*256;
|
||||
uint8 *dest,*mal,*mork;
|
||||
|
||||
if(!(mal=mork=dest=(uint8 *)FCEU_dmalloc((totallines<<8)+totallines)))
|
||||
int bufsize = (256*3+1)*totallines;
|
||||
if(!(mal=mork=dest=(uint8 *)FCEU_dmalloc(bufsize)))
|
||||
goto PNGerr;
|
||||
// mork=dest=XBuf;
|
||||
|
||||
|
@ -632,11 +625,18 @@ int SaveSnapshot(void)
|
|||
{
|
||||
*dest=0; // No filter.
|
||||
dest++;
|
||||
for(x=256;x;x--,tmp++,dest++)
|
||||
*dest=*tmp;
|
||||
for(x=256;x;x--)
|
||||
{
|
||||
extern u32 ModernDeemphColorMap(u8* src);
|
||||
u32 color = ModernDeemphColorMap(tmp);
|
||||
*dest++=(color>>0x10)&0xFF;
|
||||
*dest++=(color>>0x08)&0xFF;
|
||||
*dest++=(color>>0x00)&0xFF;
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
|
||||
if(compress(compmem,&compmemsize,mork,(totallines<<8)+totallines)!=Z_OK)
|
||||
if(compress(compmem,&compmemsize,mork,bufsize)!=Z_OK)
|
||||
{
|
||||
if(mal) free(mal);
|
||||
goto PNGerr;
|
||||
|
|
Loading…
Reference in New Issue