asp.net - Convert varbinary(max) to image,resize and save it in a folder using c# or vb.net? -


public static binarytoimage(system.data.linq.binary binarydata) {     if (binarydata == null) {     return null;     }     byte[] buffer = binarydata.toarray();     system.drawing.image newimage = default(system.drawing.image);     memorystream memstream = new memorystream();     memstream.write(buffer, 0, buffer.length);     using (memorystream strefgham = new memorystream(buffer)) {        newimage = system.drawing.image.fromstream(strefgham);        return newimage;     } } public static double getpercent(double width,double height,int originalwidth,int originalheight)  {     if (width <= originalwidth && height <= originalheight) {     return 1.0;     } else          {     double wid = (originalwidth / width);     double hei = (originalheight / height);     return (wid < hei) ? wid : hei;    } }      system.drawing.image newimage = default(system.drawing.image);    newimage = binarytoimage(varbinaryname.toarray());    double perc = getpercent(newimage.width, newimage.height, 300, 300);    double newwidth = newimage.width * perc;    double newheight = newimage.height * perc;    int disweight = convert.toint32(newwidth);    int disheight = convert.toint32(newheight); 

so far able convert varbinary(max) image, , resized it.but not able save in folder. bitmap? suggestions?

hey add line save image in folder

if (!directory.exists("d:\test"))         {             directory.createdirectory("d:\test");         } newimage.save(@"d:\test\new.jpg", origimage.rawformat); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -