hedgewars/uMisc.pas
changeset 10015 4feced261c68
parent 9998 736015b847e3
parent 9958 5a222923c8f8
child 10108 c68cf030eded
equal deleted inserted replaced
10014:56d2f2d5aad8 10015:4feced261c68
    46          filename: shortstring;
    46          filename: shortstring;
    47          width, height: LongInt;
    47          width, height: LongInt;
    48          size: QWord;
    48          size: QWord;
    49          end;
    49          end;
    50 
    50 
    51 var conversionFormat: PSDL_PixelFormat;
    51 var conversionFormat : PSDL_PixelFormat;
    52 
    52 
    53 procedure movecursor(dx, dy: LongInt);
    53 procedure movecursor(dx, dy: LongInt);
    54 var x, y: LongInt;
    54 var x, y: LongInt;
    55 begin
    55 begin
    56 if (dx = 0) and (dy = 0) then exit;
    56 if (dx = 0) and (dy = 0) then exit;
    65 // this funtion will be executed in separate thread
    65 // this funtion will be executed in separate thread
    66 function SaveScreenshot(screenshot: pointer): LongInt; cdecl; export;
    66 function SaveScreenshot(screenshot: pointer): LongInt; cdecl; export;
    67 var i: LongInt;
    67 var i: LongInt;
    68     png_ptr: ^png_struct;
    68     png_ptr: ^png_struct;
    69     info_ptr: ^png_info;
    69     info_ptr: ^png_info;
    70     f: file;
    70     f: File;
    71     image: PScreenshot;
    71     image: PScreenshot;
    72 begin
    72 begin
    73 image:= PScreenshot(screenshot);
    73 image:= PScreenshot(screenshot);
    74 
    74 
    75 png_ptr := png_create_write_struct(png_get_libpng_ver(nil), nil, nil, nil);
    75 png_ptr := png_create_write_struct(png_get_libpng_ver(nil), nil, nil, nil);
   138     0, 0, 0, 0,     // number of colors (all)
   138     0, 0, 0, 0,     // number of colors (all)
   139     0, 0, 0, 0      // number of important colors
   139     0, 0, 0, 0      // number of important colors
   140     );
   140     );
   141     image: PScreenshot;
   141     image: PScreenshot;
   142     size: QWord;
   142     size: QWord;
       
   143     writeResult:LongInt;
   143 begin
   144 begin
   144 image:= PScreenshot(screenshot);
   145 image:= PScreenshot(screenshot);
   145 
   146 
   146 size:= image^.Width*image^.Height*4;
   147 size:= image^.Width*image^.Height*4;
   147 
   148 
   165 {$IOCHECKS OFF}
   166 {$IOCHECKS OFF}
   166 Assign(f, image^.filename);
   167 Assign(f, image^.filename);
   167 Rewrite(f, 1);
   168 Rewrite(f, 1);
   168 if IOResult = 0 then
   169 if IOResult = 0 then
   169     begin
   170     begin
   170     BlockWrite(f, head, sizeof(head));
   171     BlockWrite(f, head, sizeof(head), writeResult);
   171     BlockWrite(f, image^.buffer^, size);
   172     BlockWrite(f, image^.buffer^, size, writeResult);
   172     Close(f);
   173     Close(f);
   173     end
   174     end
   174 else
   175 else
   175     begin
   176     begin
   176     //AddFileLog('Error: Could not write to ' + filename);
   177     //AddFileLog('Error: Could not write to ' + filename);
   296 begin
   297 begin
   297     s:= p^.TeamName + ':' + IntToStr(p^.TeamHealth) + ':';
   298     s:= p^.TeamName + ':' + IntToStr(p^.TeamHealth) + ':';
   298     GetTeamStatString:= s;
   299     GetTeamStatString:= s;
   299 end;
   300 end;
   300 
   301 
   301 procedure initModule;
       
   302 {$IFDEF SDL2}
   302 {$IFDEF SDL2}
   303 const SDL_PIXELFORMAT_ABGR8888 = (1 shl 28) or (6 shl 24) or (7 shl 20) or (6 shl 16) or (32 shl 8) or 4;
   303 const SDL_PIXELFORMAT_ABGR8888 = (1 shl 28) or (6 shl 24) or (7 shl 20) or (6 shl 16) or (32 shl 8) or 4;
   304 {$ELSE}
   304 {$ELSE}
   305 const format: TSDL_PixelFormat = (
   305 const format: TSDL_PixelFormat = (
   306         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
   306         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
   307         Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
   307         Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
   308         Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift;
   308         Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift;
   309         RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
   309         RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
   310         colorkey: 0; alpha: 255);
   310         colorkey: 0; alpha: 255);
   311 {$ENDIF}
   311 {$ENDIF}
       
   312 
       
   313 procedure initModule;
   312 begin
   314 begin
   313 {$IFDEF SDL2}
   315 {$IFDEF SDL2}
   314     conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888);
   316     conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888);
   315 {$ELSE}
   317 {$ELSE}
   316     conversionFormat:= @format;
   318     conversionFormat:= @format;