I am attempting to save a bitmap image to a file that only my program can understand (this is more than just changing the file extension). I have tried using blockread/blockwrite but when I tried to load the image back to another bitmap, the bitmap is just blank. The code goes something like below.
procedure SavePic(FileName: String);
var
OldBitmap: TBitmap;
Data: File;
begin
OldBitmap:=TBitmap.Create;
OldBitmap.Picture.LoadFromFile('C:\MyPicture.Bmp') ;
AssignFile(Data,'MyPicture.Dat');
Rewrite(Data,Sizeof(Bitmap);
BlockWrite(Data,Bitmap,1);
OldBitmap.Free;
end;
procedure LoadPic(FileName: String);
var
NewBitmap: TBitmap;
Data: File;
begin
NewBitmap:=TBitmap.Create;
NewBitmap.Picture.LoadFromFile('C:\MyPicture.Bmp') ;
AssignFile(Data,'MyPicture.Dat');
Reset(Data,Sizeof(Bitmap);
BlockRead(Data,Bitmap,1);
Canvas.Draw(0,0,NewBitmap);
NewBitmap.Free;
end;
But it won't work, any suggestions or alternative ways I can save the pic without anyone being able to edit the pictures.
Bookmarks