asp.net - Conversion of BitmapImage to Byte array and Store it Into Sql Database -
i want store bitmap image byte, in run time i'm getting error like
conversion type image format type integer not valid
please 1 me
for each file uploadedfile in` doc.uploadedfiles` context.cache.remove(session.sessionid + "uploadedfile") dim stream stream = file.inputstream generatethumbnails(0.5, stream) dim documentimgname = file.filename dim imgdata byte() = new byte(viewstate("compressedimagedata")) {} dim documentsplit = documentimgname.split(".") dim imgname = documentsplit(0) dim imgext = documentsplit(1) stream.read(imgdata, 0, imgdata.length) viewstate("imgdata") = imgdata viewstate("filename") = imgname viewstate("fileextension") = imgext dim ms new memorystream() ms.write(imgdata, 0, imgdata.length) next private sub generatethumbnails(byval scalefactor double, byval sourcepath stream) using image__1 = image.fromstream(sourcepath) ' can given width of image want dim newwidth = cint(image__1.width * scalefactor) ' can given height of image want dim newheight = cint(image__1.height * scalefactor) dim thumbnailimg = new bitmap(newwidth, newheight) dim thumbgraph = graphics.fromimage(thumbnailimg) thumbgraph.compositingquality = compositingquality.highquality thumbgraph.smoothingmode = smoothingmode.highquality thumbgraph.interpolationmode = interpolationmode.highqualitybicubic dim imagerectangle = new rectangle(0, 0, newwidth, newheight) thumbgraph.drawimage(image__1, imagerectangle) viewstate("compressedimagedata") = image__1.rawformat end using end sub
you can store image data after convert byte datatype below:
dim ms new syste.io.memorystream me.picturebox1.image.save(ms, picturebox1.image.rawformat) dim byteimage() byte = ms.toarray
then can store byteimage() field wich type image or varbinary.
Comments
Post a Comment