Implemented DumpToFile() from AccelerantDriver so that screenshots can be taken.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12296 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2005-04-11 20:15:43 +00:00
parent f0b7006ca0
commit 7544c9f03b

View File

@ -1081,7 +1081,35 @@ DisplayDriverPainter::SetMode(const display_mode &mode)
bool
DisplayDriverPainter::DumpToFile(const char *path)
{
return false;
#if 0
// TODO: find out why this does not work
SaveToPNG( path,
BRect(0, 0, fDisplayMode.virtual_width - 1, fDisplayMode.virtual_height - 1),
(color_space)fDisplayMode.space,
mFrameBufferConfig.frame_buffer,
fDisplayMode.virtual_height * mFrameBufferConfig.bytes_per_row,
mFrameBufferConfig.bytes_per_row);*/
#else
// TODO: remove this when SaveToPNG works properly
// this does dump each line at a time to ensure that everything
// gets written even if we crash somewhere.
// it's a bit overkill, but works for now.
FILE *output = fopen(path, "w");
if (!output)
return false;
RenderingBuffer *back_buffer = fGraphicsCard->BackBuffer();
uint32 row = back_buffer->BytesPerRow() / 4;
for (int i = 0; i < fDisplayMode.virtual_height; i++) {
fwrite((uint32 *)back_buffer->Bits() + i * row, 4, row, output);
sync();
}
fclose(output);
sync();
#endif
return true;
}
// DumpToBitmap