bitmap.savetostream problems.

i have a bitmap and when i do this:

bitmap.SaveToFile('c:\1\2.bmp');
Bitmap.SaveToStream(Stream);
bitmap.LoadFromStream(stream);
bitmap.SaveToFile('c:\1\3.bmp');

2.bmp <> 3.bmp   why?  What should i do to correct this?
(d5 pro)
LVL 7
God_AresAsked:
Who is Participating?
 
LischkeConnect With a Mentor Commented:
Hi God_Ares, I assume the first entry in your list should be a LoadFromFile. What you need to keep in mind too is to rewind your stream:

bitmap.LoadFromStream('c:\1\2.bmp');
OldPosition := Stream.Postition;
Bitmap.SaveToStream(Stream);
Stream.Position := OldPosition;
bitmap.LoadFromStream(stream);
bitmap.SaveToFile('c:\1\3.bmp');

Ciao, Mike
0
 
LischkeCommented:
..hehe and I wrote it wrong too. The first line still should be

bitmap.LoadFromFile('c:\1\2.bmp');

Ciao, Mike
0
 
God_AresAuthor Commented:
Edited text of question.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
God_AresAuthor Commented:
k i'll test it when i'm back home,  i don't have delphi @work  :(
0
 
LischkeCommented:
And now? Will you give any comment? Even if you store the bitmap in the first line it is still needed to rewind the stream before you can read what you wrote before...

Ciao, Mike
0
 
LischkeCommented:
Oops, eMail crossing :-)

Ciao, Mike
0
 
DrDelphiCommented:
God Ares,
  I am guessing that after the SaveToStream, you need to to do a seek to set the pointer back to the beginning of the stream. For Example:


bitmap.SaveToFile('c:\1\2.bmp');
Bitmap.SaveToStream(Stream);
Stream.Seek(0,0);
bitmap.LoadFromStream(stream);
bitmap.SaveToFile('c:\1\3.bmp');


Try this and lemme know how you make out, okay?

Good luck!!
0
 
God_AresAuthor Commented:
Lischke thank you for your awnser

DrDelphi thank you 2, but Lischke gave me the same...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.