diff src/screenshot.cpp @ 8249:f495acdca6b5 draft

(svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
author frosch <frosch@openttd.org>
date Fri, 11 Jan 2008 17:12:41 +0000
parents 0e48dd14a0d8
children 7d580c9c41fb
line wrap: on
line diff
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -488,13 +488,29 @@
 	blitter->CopyImageToBuffer(src, buf, _screen.width, n, pitch);
 }
 
-/* generate a large piece of the world */
+/** generate a large piece of the world
+ * @param userdata Viewport area to draw
+ * @param buf Videobuffer with same bitdepth as current blitter
+ * @param y First line to render
+ * @param pitch Pitch of the videobuffer
+ * @param n Number of lines to render
+ */
 static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
 {
 	ViewPort *vp = (ViewPort *)userdata;
 	DrawPixelInfo dpi, *old_dpi;
 	int wx, left;
 
+	/* We are no longer rendering to the screen */
+	DrawPixelInfo old_screen = _screen;
+	bool old_disable_anim = _screen_disable_anim;
+
+	_screen.dst_ptr = buf;
+	_screen.width = pitch;
+	_screen.height = n;
+	_screen.pitch = pitch;
+	_screen_disable_anim = true;
+
 	old_dpi = _cur_dpi;
 	_cur_dpi = &dpi;
 
@@ -506,6 +522,7 @@
 	dpi.left = 0;
 	dpi.top = y;
 
+	/* Render viewport in blocks of 1600 pixels width */
 	left = 0;
 	while (vp->width - left != 0) {
 		wx = min(vp->width - left, 1600);
@@ -520,6 +537,10 @@
 	}
 
 	_cur_dpi = old_dpi;
+
+	/* Switch back to rendering to the screen */
+	_screen = old_screen;
+	_screen_disable_anim = old_disable_anim;
 }
 
 static char *MakeScreenshotName(const char *ext)