anchor.diff:        end;
     end;
   
  +  InputStream.Free;
  +  OutputStream.Free;
  +end;
  +
  +
  +procedure TKMSpritePackEdit.SaveToRXXFile(const aFileName: string);
  +var
  +  I: Integer;
  +  InputStream: TMemoryStream;
  +  OutputStream: TFileStream;
  +  CompressionStream: TCompressionStream;
  +begin
  +  // No image was loaded yet
  +  //@Rey: Perhaps we should erase the file in such case, otherwise mapmaker will have to go into folder to delete rxx himself if he decided to "clear" it
  +  if IsEmpty then Exit;
  +
  +  ForceDirectories(ExtractFilePath(aFileName));
  +
  +  InputStream := TMemoryStream.Create;
  +
  +  InputStream.Write(fRXData.Count, 4);
  +  InputStream.Write(fRXData.Flag[1], fRXData.Count);
  +
  +  for I := 1 to fRXData.Count do
  +    if fRXData.Flag[I] = 1 then
  +    begin
  +      InputStream.Write(fRXData.Size[I].X, SizeOf(fRXData.Size[I]));
  +      InputStream.Write(fRXData.Pivot[I].X, SizeOf(fRXData.Pivot[I]));
  +
  +      if fRT = rxUnits then
  +        InputStream.Write(fRXData.SizeNoShadow[I].left, SizeOf(fRXData.SizeNoShadow[I]));
  +      InputStream.Write(fRXData.RGBA[I, 0], 4 * fRXData.Size[I].X * fRXData.Size[I].Y);
  +      InputStream.Write(fRXData.HasMask[I], 1);
  +      if fRXData.HasMask[I] then
  +        InputStream.Write(fRXData.Mask[I, 0], fRXData.Size[I].X * fRXData.Size[I].Y);
  +    end;
     OutputStream := TFileStream.Create(aFileName, fmCreate);
     CompressionStream := TCompressionStream.Create(clMax, OutputStream);
     InputStream.Position := 0;
  
positive.code: 
    ForceDirectories(ExtractFilePath(aFileName));
  
    InputStream := TMemoryStream.Create;
  
    //Sprite info
    InputStream.Write(fRXData.Count, 4);
  
negative.code: end;
  
  
  procedure TKMSpritePackEdit.GetImageToBitmap(aIndex: Integer; aBmp, aMask: TBitmap);
  var
    I, K, W, H: Integer;
  