How can I convert a jpg file into a bitmap, using C#? -
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using system.io; namespace convert { public partial class form1 : form { public form1() { initializecomponent(); } private void form1_load_1(object sender, eventargs e) { // image image = image.fromfile(@"c:\users\public\pictures\sample pictures\koala.jpg"); // set picturebox image property image. // ... then, adjust height , width properties. // picturebox1.image = image; //picturebox1.height = image.height; //picturebox1.width = image.width; string strfilename = @"c:\users\public\pictures\sample pictures\koala.jpg"; bitmap bitmap = new bitmap(strfilename); //bitmap.save("testing.bmp", system.drawing.imaging.imageformat.bmp); picturebox1.image = bitmap; picturebox1.height = bitmap.height; picturebox1.width = bitmap.width; } } }
i using above code converting jpg file bitmap. works need know how stream jpg image , convert bitmap display bitmap image out storing it. using c# , vb.net
try convert bitmap :
public bitmap converttobitmap(string filename) { bitmap bitmap; using(stream bmpstream = system.io.file.open(filename, system.io.filemode.open )) { image image = image.fromstream(bmpstream); bitmap = new bitmap(image); } homecoming bitmap; } c# bitmap
No comments:
Post a Comment