Mercurial > hg > openttd
comparison 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 |
comparison
equal
deleted
inserted
replaced
8248:836273f128b5 | 8249:f495acdca6b5 |
---|---|
486 Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); | 486 Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
487 void *src = blitter->MoveTo(_screen.dst_ptr, 0, y); | 487 void *src = blitter->MoveTo(_screen.dst_ptr, 0, y); |
488 blitter->CopyImageToBuffer(src, buf, _screen.width, n, pitch); | 488 blitter->CopyImageToBuffer(src, buf, _screen.width, n, pitch); |
489 } | 489 } |
490 | 490 |
491 /* generate a large piece of the world */ | 491 /** generate a large piece of the world |
492 * @param userdata Viewport area to draw | |
493 * @param buf Videobuffer with same bitdepth as current blitter | |
494 * @param y First line to render | |
495 * @param pitch Pitch of the videobuffer | |
496 * @param n Number of lines to render | |
497 */ | |
492 static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, uint n) | 498 static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, uint n) |
493 { | 499 { |
494 ViewPort *vp = (ViewPort *)userdata; | 500 ViewPort *vp = (ViewPort *)userdata; |
495 DrawPixelInfo dpi, *old_dpi; | 501 DrawPixelInfo dpi, *old_dpi; |
496 int wx, left; | 502 int wx, left; |
503 | |
504 /* We are no longer rendering to the screen */ | |
505 DrawPixelInfo old_screen = _screen; | |
506 bool old_disable_anim = _screen_disable_anim; | |
507 | |
508 _screen.dst_ptr = buf; | |
509 _screen.width = pitch; | |
510 _screen.height = n; | |
511 _screen.pitch = pitch; | |
512 _screen_disable_anim = true; | |
497 | 513 |
498 old_dpi = _cur_dpi; | 514 old_dpi = _cur_dpi; |
499 _cur_dpi = &dpi; | 515 _cur_dpi = &dpi; |
500 | 516 |
501 dpi.dst_ptr = buf; | 517 dpi.dst_ptr = buf; |
504 dpi.pitch = pitch; | 520 dpi.pitch = pitch; |
505 dpi.zoom = ZOOM_LVL_WORLD_SCREENSHOT; | 521 dpi.zoom = ZOOM_LVL_WORLD_SCREENSHOT; |
506 dpi.left = 0; | 522 dpi.left = 0; |
507 dpi.top = y; | 523 dpi.top = y; |
508 | 524 |
525 /* Render viewport in blocks of 1600 pixels width */ | |
509 left = 0; | 526 left = 0; |
510 while (vp->width - left != 0) { | 527 while (vp->width - left != 0) { |
511 wx = min(vp->width - left, 1600); | 528 wx = min(vp->width - left, 1600); |
512 left += wx; | 529 left += wx; |
513 | 530 |
518 ScaleByZoom((y + n) - vp->top, vp->zoom) + vp->virtual_top | 535 ScaleByZoom((y + n) - vp->top, vp->zoom) + vp->virtual_top |
519 ); | 536 ); |
520 } | 537 } |
521 | 538 |
522 _cur_dpi = old_dpi; | 539 _cur_dpi = old_dpi; |
540 | |
541 /* Switch back to rendering to the screen */ | |
542 _screen = old_screen; | |
543 _screen_disable_anim = old_disable_anim; | |
523 } | 544 } |
524 | 545 |
525 static char *MakeScreenshotName(const char *ext) | 546 static char *MakeScreenshotName(const char *ext) |
526 { | 547 { |
527 static char filename[MAX_PATH]; | 548 static char filename[MAX_PATH]; |