how to save image using memory stream and not use savefiledialog

Posted by Ahmedsa under C# on 1/29/2017 | Points: 10 | Views : 253 | Status : [Member] | Replies : 1
I generate qr code for name and country and member

qr code generated without any problem

but i need to use memory stream and not use save file dialog

my code as below

using (SaveFileDialog sv = new SaveFileDialog() { Filter = "JPEG|.jpg", ValidateNames = true })
{
if (sv.ShowDialog() == DialogResult.OK)
{
MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
encoder.QRCodeScale = 8;


string encoding = "UserName : " + textBox4.Text + "\r\n" + "Country : " + comboBox3.Text + "\r\n" + "Membership :" + comboBox5.Text;


Bitmap bmp = encoder.Encode(encoding);
pictureBox1.Image = bmp;
path = sv.FileName;
bmp.Save(path, ImageFormat.Jpeg);
}

}

How to replace save file dialog by using memory stream ?




Responses

Posted by: Qutyquteshweta on: 2/15/2017 [Member] Starter | Points: 25

Up
0
Down
Hi Ahmedsa,
Here is the sample code:

string encoding = "UserName : " + textBox4.Text + "\r\n" + "Country : " + comboBox3.Text + "\r\n" + "Membership :" + comboBox5.Text;

byte[] buffer = Encoding.ASCII.GetBytes(encoding);
MemoryStream ms = new MemoryStream(buffer);
ms.Close();



Regards,
Shweta
http://www.shwetalodha.blogspot.com

Ahmedsa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response