--- a/hedgewars/uMisc.pas Thu Dec 18 00:03:53 2014 +0300
+++ b/hedgewars/uMisc.pas Sat Jan 03 23:46:26 2015 +0300
@@ -28,7 +28,7 @@
procedure movecursor(dx, dy: LongInt);
function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
-function MakeScreenshot(filename: shortstring; k: LongInt): boolean;
+function MakeScreenshot(filename: shortstring; k: LongInt; dump: LongWord): boolean;
function GetTeamStatString(p: PTeam): shortstring;
{$IFDEF SDL2}
function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline;
@@ -221,12 +221,13 @@
// captures and saves the screen. returns true on success.
// saved image will be k times smaller than original (useful for saving thumbnails).
-function MakeScreenshot(filename: shortstring; k: LongInt): Boolean;
+function MakeScreenshot(filename: shortstring; k: LongInt; dump: LongWord): boolean;
var p: Pointer;
size: QWord;
image: PScreenshot;
format: GLenum;
ext: string[4];
+ x,y: LongWord;
begin
{$IFDEF PNG_SCREENSHOTS}
format:= GL_RGBA;
@@ -236,7 +237,9 @@
ext:= '.bmp';
{$ENDIF}
-size:= toPowerOf2(cScreenWidth) * toPowerOf2(cScreenHeight) * 4;
+if dump > 0 then
+ size:= LAND_WIDTH*LAND_HEIGHT*4
+else size:= toPowerOf2(cScreenWidth) * toPowerOf2(cScreenHeight) * 4;
p:= GetMem(size); // will be freed in SaveScreenshot()
// memory could not be allocated
@@ -248,18 +251,55 @@
end;
// read pixels from the front buffer
-glReadPixels(0, 0, cScreenWidth, cScreenHeight, format, GL_UNSIGNED_BYTE, p);
-
+if dump > 0 then
+ begin
+ for y:= 0 to LAND_HEIGHT-1 do
+ for x:= 0 to LAND_WIDTH-1 do
+ if dump = 2 then
+ PLongWordArray(p)^[y*LAND_WIDTH+x]:= LandPixels[LAND_HEIGHT-1-y, x]
+ else
+ begin
+ if Land[LAND_HEIGHT-1-y, x] and lfIndestructible = lfIndestructible then
+ PLongWordArray(p)^[y*LAND_WIDTH+x]:= (AMask or RMask)
+ else if Land[LAND_HEIGHT-1-y, x] and lfIce = lfIce then
+ PLongWordArray(p)^[y*LAND_WIDTH+x]:= (AMask or BMask)
+ else if Land[LAND_HEIGHT-1-y, x] and lfBouncy = lfBouncy then
+ PLongWordArray(p)^[y*LAND_WIDTH+x]:= (AMask or GMask)
+ else if Land[LAND_HEIGHT-1-y, x] and lfObject = lfObject then
+ PLongWordArray(p)^[y*LAND_WIDTH+x]:= $FFFFFFFF
+ else if Land[LAND_HEIGHT-1-y, x] and lfBasic = lfBasic then
+ PLongWordArray(p)^[y*LAND_WIDTH+x]:= AMask
+ else
+ PLongWordArray(p)^[y*LAND_WIDTH+x]:= 0
+ end
+ end
+else
+ begin
+ glReadPixels(0, 0, cScreenWidth, cScreenHeight, format, GL_UNSIGNED_BYTE, p);
{$IFDEF USE_VIDEO_RECORDING}
-ReduceImage(p, cScreenWidth, cScreenHeight, k);
+ ReduceImage(p, cScreenWidth, cScreenHeight, k)
{$ENDIF}
+ end;
// allocate and fill structure that will be passed to new thread
New(image); // will be disposed in SaveScreenshot()
-//image^.filename:= shortstring(UserPathPrefix) + filename + ext;
+{if dump = 2 then
+ image^.filename:= shortstring(UserPathPrefix) + filename + '_landpixels' + ext
+else if dump = 1 then
+ image^.filename:= shortstring(UserPathPrefix) + filename + '_land' + ext
+else image^.filename:= shortstring(UserPathPrefix) + filename + ext;}
image^.filename:= filename + ext;
-image^.width:= cScreenWidth div k;
-image^.height:= cScreenHeight div k;
+
+if dump <> 0 then
+ begin
+ image^.width:= LAND_WIDTH;
+ image^.height:= LAND_HEIGHT
+ end
+else
+ begin
+ image^.width:= cScreenWidth div k;
+ image^.height:= cScreenHeight div k
+ end;
image^.size:= size;
image^.buffer:= p;