Hi,
I am creating an image file using the code below
Bitmap newImage = new Bitmap(Convert.ToInt32(dtDevice.Rows[0]["LogoWidth"]), Convert.ToInt32(dtDevice.Rows[0]["LogoHeight"]));
using (Graphics gr = Graphics.FromImage(newImage))
{
gr.SmoothingMode = SmoothingMode.AntiAlias;
gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
gr.DrawImage(SourceLogo, new Rectangle(0, 0, Convert.ToInt32(dtDevice.Rows[0]["LogoWidth"].ToString()), Convert.ToInt32(dtDevice.Rows[0]["LogoHeight"].ToString())));
}
fileName = dr["DeviceID"].ToString() + "_" + objBusiness.ID + "_" + objBusiness.ResellerId + imgExtension;
newImage.Save(filePath + fileName);
The save method saves the file in the specified folder. But before saving i want to get the raw data of the image . Currently am doing this
FileInfo fileInfo = new FileInfo(tempFilePath + fileName);
byte[] fileData = new byte[fileInfo.Length];
DataTable dtBusiness = new Businesses().GetBusiness(objBusiness.ID);
if (dtBusiness != null && dtBusiness.Rows.Count > 0)
{
httpUserName = dtBusiness.Rows[0]["httpUserName"].ToString();
httpPassword = dtBusiness.Rows[0]["httpPassword"].ToString();
}
fileData = File.ReadAllBytes(filePath + fileName);
using (FileStream fs = new FileStream(filePath + fileName, FileMode.Open, FileAccess.Read))
{
fileData = new byte[fs.Length];
fs.Read(fileData, 0, Convert.ToInt32(fs.Length));
fs.Close();
}
imageContent = Convert.ToBase64String(fileData);
so that image content will be a base64String.But the problem is that to read the file bytes i have to save it which i want to skip.
Is it possible to get it before saving in the folder?Thanks in advance