سلام دوستان . من یه عکس و بصورت باینری باز میکنم و میخوام یکجا دیگه ذخیره کنم . ولی الان وقتی عکس جدید و میسازم از نظر سایز درسته ولی عکسی نشون نمیده !
سلام دوستان . من یه عکس و بصورت باینری باز میکنم و میخوام یکجا دیگه ذخیره کنم . ولی الان وقتی عکس جدید و میسازم از نظر سایز درسته ولی عکسی نشون نمیده !
private void button1_Click(object sender, EventArgs e)
{
System.IO.FileStream fs;
fs = new System.IO.FileStream("C:\\1.gif",
System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read);
byte[] rawData = new byte[fs.Length];
fs.Read(rawData, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
byte[] myData = new byte[rawData.Length];
WriteToFile(ref myData);
}
private void WriteToFile(ref byte[] Buffer)
{
FileStream newFile;
newFile = new FileStream("C:\\2.gif", FileMode.Create,
System.IO.FileAccess.Write);
newFile.Write(Buffer, 0, System.Convert.ToInt32(Buffer.Length));
newFile.Close();
}
برای ذخیره از روش زیر استفاده کنید :
MemoryStream ms=New MemoryStream(Buffer,0,Buffer.Lenght);
Image im=new Image.FromStream(ms);
im.SaveToFile(path);
من اینکار رو قبلا انجام دادم ولی متاسفانه جواب نداد :
FileStream newFile = new FileStream("C:\\2.gif", FileMode.Create, System.IO.FileAccess.Write);
MemoryStream newFile = new MemoryStream();
newFile.Write(Buffer, 0, Buffer.Length);
Bitmap bitmap = new Bitmap(newFile);
bitmap.Save("C:\\2.gif", System.Drawing.Imaging.ImageFormat.Gif);
newFile.Close();