procedure TForm5.UploadImage;
var stream : TMemoryStream;
saveParams : TBitmapCodecSaveParams;
aBitmapSurface: TBitmapSurface;
aPath: string;
begin
memo1.lines.add('starting upload image stream');
aPath := System.IOUtils.TPath.GetDocumentsPath + System.SysUtils.PathDelim;
memo1.lines.add('image path: '+aPath);
Application.ProcessMessages;
stream := TMemoryStream.Create;
try
aBitmapSurface := TBitmapSurface.Create;
aBitmapSurface.Assign(Image1.bitmap);
saveparams.Quality:=20;
//TBitmapCodecManager.SaveToStream(Stream, aBitmapSurface, '.jpg',@saveParams);
TBitmapCodecManager.SaveToFile(aPath+'mypicture.jpg',aBitmapSurface);
try
if not FTPConnected then
Exit;
Application.ProcessMessages;
//FTPClient.Put(stream,'mymobilepic.jpg',true,0);
FTPClient.Put( aPath+'mypicture.jpg','mywebpicture.jpg',false,0);
Application.ProcessMessages;
FTPClient.Disconnect;
memo1.lines.add('finished upload image stream');
except
on e:
exception do
memo1.lines.add('error uploading image stream: '+e.message);
end;
finally
aBitmapSurface.Free;
stream.Free;
end;
end;