hedgewars/uMisc.pas
branchui-scaling
changeset 15288 c4fd2813b127
parent 14894 9b292184d793
child 15319 fe705efbfc52
equal deleted inserted replaced
13395:0135e64c6c66 15288:c4fd2813b127
    24 uses SDLh, uConsts, GLunit, uTypes;
    24 uses SDLh, uConsts, GLunit, uTypes;
    25 
    25 
    26 procedure initModule;
    26 procedure initModule;
    27 procedure freeModule;
    27 procedure freeModule;
    28 
    28 
    29 procedure movecursor(dx, dy: LongInt);
       
    30 function  doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
    29 function  doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface;
    31 function MakeScreenshot(filename: shortstring; k: LongInt; dump: LongWord): boolean;
    30 function MakeScreenshot(filename: shortstring; k: LongInt; dump: LongWord): boolean;
    32 function  GetTeamStatString(p: PTeam): shortstring;
    31 function  GetTeamStatString(p: PTeam): shortstring;
    33 function  SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline;
    32 function  SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline;
    34 
    33 
    43          width, height: LongInt;
    42          width, height: LongInt;
    44          size: QWord;
    43          size: QWord;
    45          end;
    44          end;
    46 
    45 
    47 var conversionFormat : PSDL_PixelFormat;
    46 var conversionFormat : PSDL_PixelFormat;
    48 
       
    49 procedure movecursor(dx, dy: LongInt);
       
    50 var x, y: LongInt;
       
    51 begin
       
    52 if (dx = 0) and (dy = 0) then exit;
       
    53 
       
    54 SDL_GetMouseState(@x, @y);
       
    55 Inc(x, dx);
       
    56 Inc(y, dy);
       
    57 SDL_WarpMouse(x, y);
       
    58 end;
       
    59 
    47 
    60 {$IFDEF PNG_SCREENSHOTS}
    48 {$IFDEF PNG_SCREENSHOTS}
    61 // this funtion will be executed in separate thread
    49 // this funtion will be executed in separate thread
    62 function SaveScreenshot(screenshot: pointer): LongInt; cdecl; export;
    50 function SaveScreenshot(screenshot: pointer): LongInt; cdecl; export;
    63 var i: LongInt;
    51 var i: LongInt;
   183 
   171 
   184 {$ENDIF} // no PNG_SCREENSHOTS
   172 {$ENDIF} // no PNG_SCREENSHOTS
   185 
   173 
   186 {$IFDEF USE_VIDEO_RECORDING}
   174 {$IFDEF USE_VIDEO_RECORDING}
   187 // make image k times smaller (useful for saving thumbnails)
   175 // make image k times smaller (useful for saving thumbnails)
   188 procedure ReduceImage(img: PByte; width, height, k: LongInt);
   176 procedure ReduceImage(img: PByteArray; width, height, k: LongInt);
   189 var i, j, i0, j0, w, h, r, g, b: LongInt;
   177 var i, j, i0, j0, w, h, r, g, b: LongInt;
   190 begin
   178 begin
   191     w:= width  div k;
   179     w:= width  div k;
   192     h:= height div k;
   180     h:= height div k;
   193 
   181 
   201                 g:= 0;
   189                 g:= 0;
   202                 b:= 0;
   190                 b:= 0;
   203                 for i0:= 0 to k-1 do
   191                 for i0:= 0 to k-1 do
   204                     for j0:= 0 to k-1 do
   192                     for j0:= 0 to k-1 do
   205                     begin
   193                     begin
   206                         inc(r, img[4*(width*(i*k+i0) + j*k+j0)+0]);
   194                         inc(r, img^[4*(width*(i*k+i0) + j*k + j0)+0]);
   207                         inc(g, img[4*(width*(i*k+i0) + j*k+j0)+1]);
   195                         inc(g, img^[4*(width*(i*k+i0) + j*k + j0)+1]);
   208                         inc(b, img[4*(width*(i*k+i0) + j*k+j0)+2]);
   196                         inc(b, img^[4*(width*(i*k+i0) + j*k + j0)+2]);
   209                     end;
   197                     end;
   210                 img[4*(w*i + j)+0]:= r div (k*k);
   198                 img^[4*(w*i + j)+0]:= r div (k*k);
   211                 img[4*(w*i + j)+1]:= g div (k*k);
   199                 img^[4*(w*i + j)+1]:= g div (k*k);
   212                 img[4*(w*i + j)+2]:= b div (k*k);
   200                 img^[4*(w*i + j)+2]:= b div (k*k);
   213                 img[4*(w*i + j)+3]:= 255;
   201                 img^[4*(w*i + j)+3]:= 255;
   214             end;
   202             end;
   215     end;
   203     end;
   216 end;
   204 end;
   217 {$ENDIF}
   205 {$ENDIF}
   218 
   206