I have a problem with the WriteHidenData and ReadHidenData routines. It's not possible to read out hidden data again, after the image is saved to file and loaded again.
FMaxInfoSize := ImageEnView1.Proc.GetHiddenDataSpace; //Be sure not to work at the limit FMaxInfoSize := ceil(FMaxInfoSize * 0.9); //adapt memo that will contain the text mmoTextMessage.MaxLength := FMaxInfoSize;
//hide the contents of the memo in the image procedure TForm10.Button2Click(Sender: TObject); var ss: TMemoryStream; begin ss := TMemoryStream.Create; try mmoTextMessage.Lines.SaveToStream(ss); ss.Position := 0; ImageEnView1.Proc.WriteHiddenData(ss.memory, ss.size); finally freeandnil(ss); end; end; //Read the hidden text procedure TForm10.Button3Click(Sender: TObject); var ss: TMemoryStream; begin Memo1.Clear; ss := TMemoryStream.Create; try ss.Size := ImageEnView1.Proc.ReadHiddenData(nil, 0); if ss.Size > 0 then begin ImageEnView1.Proc.ReadHiddenData(ss.memory, ss.Size); Memo1.Lines.LoadFromStream(ss); end; finally freeandnil(ss); end; end;
Everything works fine UNTIL I SAVE the file and LOAD it again. I'm aware of the file formats that support hidden text (bmp was used). Here is the routine, that saves the image with the hidden text
procedure TForm10.Button4Click(Sender: TObject); begin SaveImageEnDialog1.InitialDir := ExtractFileDir ( ImageEnView1.IO.Params.FileName ); SaveImageEnDialog1.FileName := ExtractFilename ( ImageEnView1.IO.Params.FileName ); if SaveImageEnDialog1.Execute then begin ImageEnView1.IO.SaveToFile(SaveImageEnDialog1.FileName); end; end;
To load the file ImageEnView1.IO.LoadFromFile is used. -------------------------- It is no problem to hide and unhide a few characters or words, but storing more data does not work.
Is this a bug or what is the problem? --------------------------- While waiting for your response, I realized, that the same/comparable error occurs within your encryption demo programm. Everything works fine until you save and reopen the image. After reopening, it is not possible to decrypt the image again!
|