c# - How to convert ImageSource to Byte array? -
c# - How to convert ImageSource to Byte array? -
i utilize leadtools scanning.
i want convert scanning image byte.
void twainsession_acquirepage(object sender, twainacquirepageeventargs e) { scanimage = e.image.clone(); imagesource source = rasterimageconverter.converttosource(scanimage, converttosourceoptions.none); }
how convert imagesource byte array?
unless explicitly need imagesource object, there's no need convert one. can byte array containing pixel info straight leadtools.rasterimage using code:
int totalpixelbytes = e.image.bytesperline * e.image.height; byte[] bytearray = new byte[totalpixelbytes]; e.image.getrow(0, bytearray, 0, totalpixelbytes);
note gives raw pixel data.
if need memory stream or byte array contains finish image such jpeg, not need convert source. can utilize leadtools.rastercodecs class this:
rastercodecs codecs = new rastercodecs(); system.io.memorystream memstream = new system.io.memorystream(); codecs.save(e.image, memstream, rasterimageformat.jpeg, 24);
c# wpf leadtools-sdk
Comments
Post a Comment