mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Api was too confusing for people.
This commit is contained in:
parent
2025f00f88
commit
71d70d896f
@ -701,6 +701,7 @@ bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle
|
||||
memcpy(data, map.pData, map.RowPitch * rc.GetHeight());
|
||||
|
||||
saved_png = TextureToPng(data, map.RowPitch, filename.c_str(), rc.GetWidth(), rc.GetHeight(), false);
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
D3D::context->Unmap(s_screenshot_texture, 0);
|
||||
|
@ -71,6 +71,7 @@ bool TextureCache::TCacheEntry::Save(const char filename[], unsigned int level)
|
||||
memcpy(data, map.pData, map.RowPitch * desc.Height);
|
||||
|
||||
saved_png = TextureToPng(data, map.RowPitch, filename, desc.Width, desc.Height);
|
||||
delete[] data;
|
||||
}
|
||||
D3D::context->Unmap(pNewTexture, 0);
|
||||
}
|
||||
|
@ -1825,7 +1825,11 @@ bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle
|
||||
|
||||
// Turn image upside down
|
||||
FlipImageData(data, W, H, 4);
|
||||
return TextureToPng(data, W*4, filename.c_str(), W, H, false);
|
||||
bool success = TextureToPng(data, W*4, filename.c_str(), W, H, false);
|
||||
delete[] data;
|
||||
|
||||
return success;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -78,8 +78,9 @@ bool SaveTexture(const char* filename, u32 textarget, u32 tex, int virtual_width
|
||||
delete[] data;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TextureToPng(data, width*4, filename, width, height, true);
|
||||
bool success = TextureToPng(data, width * 4, filename, width, height, true);
|
||||
delete[] data;
|
||||
return success;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
@ -57,6 +57,7 @@ void SaveTexture(const char* filename, u32 texmap, s32 mip)
|
||||
GetTextureRGBA(data, texmap, mip, width, height);
|
||||
|
||||
(void)TextureToPng(data, width*4, filename, width, height, true);
|
||||
delete[] data;
|
||||
|
||||
}
|
||||
|
||||
@ -140,6 +141,7 @@ void DumpEfb(const char* filename)
|
||||
}
|
||||
|
||||
(void)TextureToPng(data, EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true);
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void DumpDepth(const char* filename)
|
||||
@ -161,6 +163,7 @@ void DumpDepth(const char* filename)
|
||||
}
|
||||
|
||||
(void)TextureToPng(data, EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true);
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void DrawObjectBuffer(s16 x, s16 y, u8 *color, int bufferBase, int subBuffer, const char *name)
|
||||
@ -241,6 +244,7 @@ void OnObjectEnd()
|
||||
|
||||
(void)TextureToPng((u8*)ObjectBuffer[i], EFB_WIDTH * 4, filename.c_str(), EFB_WIDTH, EFB_HEIGHT, true);
|
||||
memset(ObjectBuffer[i], 0, sizeof(ObjectBuffer[i]));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,6 +145,8 @@ void SWRenderer::DrawTexture(u8 *texture, int width, int height)
|
||||
u8 *data = new u8[width * 4 * height];
|
||||
memcpy(data, texture, sizeof(u8) * 4 * width * height);
|
||||
TextureToPng(data, width*4, s_sScreenshotName.c_str(), width, height, false);
|
||||
delete[] data;
|
||||
|
||||
// Reset settings
|
||||
s_sScreenshotName.clear();
|
||||
s_bScreenshot = false;
|
||||
|
@ -24,8 +24,6 @@ TextureToPng
|
||||
|
||||
Inputs:
|
||||
data : This is an array of RGBA with 8 bits per channel. 4 bytes for each pixel.
|
||||
data is a newly allocated memory and must have delete[] run on it before returning.
|
||||
|
||||
row_stride: Determines the amount of bytes per row of pixels.
|
||||
*/
|
||||
bool TextureToPng(u8* data, int row_stride, const char* filename, int width, int height, bool saveAlpha)
|
||||
@ -109,8 +107,5 @@ finalise:
|
||||
if (info_ptr != NULL) png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||
if (png_ptr != NULL) png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
|
||||
|
||||
// Our duty to delete the inputted data.
|
||||
delete[] data;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user