Olá tenho método que faz tratamento de uma imagem, esse método gera um bitmap…
tenho um outro método (WebClient) que faz o upload da imagem…
meu problema é o seguinte, não consigo passar por parâmetro a imagem bitmap, só aceita string
tem alguma maneira de eu fazer o tratamento da imagem e depois subir?
segue o código abaixo:
void SaveImage(string file)
{
try
{
int newwidthimg = 0;
Image image = Image.FromFile(file);
float width = (float)image.Size.Width;
float height = (float)image.Size.Height;
if (width >= height)
newwidthimg = 600;
else
newwidthimg = 450;
float AspectRatio = (float)image.Size.Width / (float)image.Size.Height;
int newHeight = Convert.ToInt32(newwidthimg / AspectRatio);
Bitmap bitmap = new Bitmap(newwidthimg, newHeight);
Graphics graph = Graphics.FromImage(bitmap);
graph.CompositingQuality = CompositingQuality.HighQuality;
graph.SmoothingMode = SmoothingMode.HighQuality;
graph.InterpolationMode = InterpolationMode.HighQualityBicubic;
var rectangle = new Rectangle(0, 0, newwidthimg, newHeight);
graph.DrawImage(image, rectangle);
Upload(caminhoFTP, bitmap); // o parametro bitmap não funciona
//tentei bitmap.Save("C:\"); ele só aceita salvar no PC
graph.Dispose();
image.Dispose();
}
catch (Exception ex)
{
throw ex;
}
}
private void Upload(string ftpServer, string img)
{
using (WebClient client = new WebClient())
{
client.Credentials = new NetworkCredential(userName, password);
client.UploadFile(ftpServer, img);
}
}