Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://code.google.com/p/dolphin-emu
  • Loading branch information
lioncash committed Nov 16, 2013
2 parents ee32c8b + 4a9c8e6 commit c46aabc
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/D3D/Src/Render.cpp
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoBackends/D3D/Src/TextureCache.cpp
Expand Up @@ -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);
}
Expand Down
6 changes: 5 additions & 1 deletion Source/Core/VideoBackends/OGL/Src/Render.cpp
Expand Up @@ -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;

}

}
5 changes: 3 additions & 2 deletions Source/Core/VideoBackends/OGL/Src/TextureCache.cpp
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/VideoBackends/Software/Src/DebugUtil.cpp
Expand Up @@ -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;

}

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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]));

}
}

Expand Down
4 changes: 1 addition & 3 deletions Source/Core/VideoBackends/Software/Src/SWRenderer.cpp
Expand Up @@ -142,9 +142,7 @@ void SWRenderer::DrawTexture(u8 *texture, int width, int height)
if (s_bScreenshot)
{
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
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);
TextureToPng(texture, width*4, s_sScreenshotName.c_str(), width, height, false);
// Reset settings
s_sScreenshotName.clear();
s_bScreenshot = false;
Expand Down
5 changes: 0 additions & 5 deletions Source/Core/VideoCommon/Src/ImageWrite.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -109,8 +107,5 @@ bool TextureToPng(u8* data, int row_stride, const char* filename, int width, int
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;
}

0 comments on commit c46aabc

Please sign in to comment.