r3nder
asked on
convert tif to png
I have an image that I have saved in a widows form and when a user goes to use it it says you have to file association - even after I associated the file typew on there pc
I am trying to convert till images to png now - the error I am geting isd connot implicitly convert type void to system.drawing.image - what am I doing wrong
I am trying to convert till images to png now - the error I am geting isd connot implicitly convert type void to system.drawing.image - what am I doing wrong
private void ShowImage(int ID)
{
try
{
int @id = ID;
string conString = ConfigurationManager.ConnectionStrings["Manager"].ToString();
SqlConnection conn = new SqlConnection(conString);
SqlDataAdapter da = new SqlDataAdapter("spx_MsgUploadFiles_Pull", conn);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.AddWithValue("@id", id);
DataSet ds = new DataSet("read");
conn.Open();
da.Fill(ds, "read");
conn.Close();
//storing the file in byte array
byte[] MyData = new byte[0];
DataRow myRow;
myRow = ds.Tables["read"].Rows[0];
MyData = (byte[])myRow["Document_File"];
string name = myRow["filename"].ToString();
int ArraySize = new int();
ArraySize = MyData.GetUpperBound(0);
if (ArraySize > -1)
{
string temp = ConfigurationManager.AppSettings["AppfileLogRootPath"];
string path = temp + name;
File.WriteAllBytes(path, MyData);
byte[] pdf = (byte[])myRow["Document_File"];
Image image;
using (System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open))
image = Image.FromStream(fs).Save(path, System.Drawing.Imaging.ImageFormat.Png); <-- error here/////////////////////////
pbImage.Image = image;
}
}
catch (Exception exShowImage)
{
MessageBox.Show(exShowImage.Message.ToString());
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Sedgwick Worked great!
ImgOperations _ImgOperations = new ImgOperations();
MemoryStream ms = new MemoryStream(byteArrayIn);
System.Drawing.Bitmap _TestBitmap = new System.Drawing.Bitmap(ms);
_TestBitmap.SetResolution(
_TestBitmap.Save(filename,
_TestBitmap.Dispose();
ms.Dispose();