unten ein kleiner Testcode zum hin und her kopieren von Bildern auf einem TImage in einen TMemoryStream.
Wenn ich in der Delphi
IDE zwei *.bmp#s in das TImage lade spielt der Code, wenn ich *.jpg in das TImage lade klappt das ganze nicht mehr.
Warum, ich dachte es egal was die quelle /Image typ war ?
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var aMemoryStream : TmemoryStream;
BMemoryStream : TmemoryStream;
begin
aMemoryStream := TmemoryStream.Create;
aMemoryStream.Seek(0, soFromBeginning);
image1.Picture.Graphic.SaveToStream(aMemoryStream);
bMemoryStream := TmemoryStream.Create;
bMemoryStream.Seek(0, soFromBeginning);
image2.Picture.Graphic.SaveToStream(bMemoryStream);
aMemoryStream.Position := 0;
bMemoryStream.Position := 0;
image2.Picture.Graphic.LoadFromStream(aMemoryStream);
image1.Picture.Graphic.LoadFromStream(bMemoryStream);
aMemoryStream.Free;
bMemoryStream.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var aMemoryStream : TmemoryStream;
BMemoryStream : TmemoryStream;
begin
aMemoryStream := TmemoryStream.Create;
aMemoryStream.Seek(0, soFromBeginning);
image1.Picture.Bitmap.SaveToStream(aMemoryStream);
bMemoryStream := TmemoryStream.Create;
bMemoryStream.Seek(0, soFromBeginning);
image2.Picture.bitmap.SaveToStream(bMemoryStream);
aMemoryStream.Position := 0;
bMemoryStream.Position := 0;
image2.Picture.bitmap.LoadFromStream(aMemoryStream);
image1.Picture.bitmap.LoadFromStream(bMemoryStream);
aMemoryStream.Free;
bMemoryStream.Free;
end;