alexiat
asked on
JPEG SaveToStream Problem
Can anyone please tell me why this doesn't work. As a test, after I called LoadFromFile I also loaded the image into a TImage component and it appears just fine. MyJPEG height and width are correct. It just doesn't load anything to stream. Aargh! Thanks.
var
ms: TMemoryStream;
MyJPEG: TJPEGImage;
begin
ms := TMemoryStream.Create;
try
MyJPEG := TJPEGImage.Create;
try
MyJPEG.LoadFromFile('image 1.jpg');
MyJPEG.SaveToStream(ms);
ms.Position := 0;
//ms.memory^ shows "(no value)" and if I try to LoadFromStream() into any image the stream is empty.
finally
MyJPEG.Free;
end;
finally
ms.Free;
end;
var
ms: TMemoryStream;
MyJPEG: TJPEGImage;
begin
ms := TMemoryStream.Create;
try
MyJPEG := TJPEGImage.Create;
try
MyJPEG.LoadFromFile('image
MyJPEG.SaveToStream(ms);
ms.Position := 0;
//ms.memory^ shows "(no value)" and if I try to LoadFromStream() into any image the stream is empty.
finally
MyJPEG.Free;
end;
finally
ms.Free;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ms.Seek(0, soFromBeginning).
I double clicked the dot... only one not ms.. but ms.
(I know you know that but I messed up so want to make certain).
John
I double clicked the dot... only one not ms.. but ms.
(I know you know that but I messed up so want to make certain).
John
ASKER
Whew. Thanks. Who knew you couldn't trust the debugger. I guess this means it is the 3rd party component who is trying to use the stream that is having problems with it. I thought I was blindly missing something.
ms..Seek(0, soFromBeginning);
Give that a try.
John