You need to write methods that write and read the information. You could do it using binary writer and reader objects.
procedure TMap.SaveToStream(Stream: TStream);
var
Writer: TBinaryWriter;
begin
Writer := TBinaryWriter.Create(Stream);
try
Writer.Write(HexRow);
Writer.Write(HexColumn);
Bitmap.SaveToStream(Stream);
finally
Writer.Free;
end;
end;
procedure TMap.LoadFromStream(Stream: TStream);
var
Reader: TBinaryReader;
begin
Reader := TBinaryReader.Create(Stream);
try
HexRow := Reader.ReadInteger;
HexColumn := Reader.ReadInteger;
Bitmap.LoadFromStream(Stream);
finally
Reader.Free;
end;
end;
Or if you wanted to be cute then you could write the bitmap first, and stuff the extra information at the end of the file. I think then that most bitmap reading code would just ignore the extra numbers you stored at the end. Of course, those values would not survive a round trip using any software other than your own.
To save to and load from a file use TFileStream
.
Of course, such a file format doesn't give you much room for future enhancement and modification. Personally I think I'd be inclined to use PNG format. This gives you compression and I believe that you can add custom metadata.