Unless you explicitly need an ImageSource object, there is no need to convert it to one. You can get an array of bytes containing pixel data directly from Leadtools.RasterImage using this code:
int totalPixelBytes = e.Image.BytesPerLine * e.Image.Height;
byte[] byteArray = new byte[totalPixelBytes];
e.Image.GetRow(0, byteArray, 0, totalPixelBytes);
Please note that this only gives you the raw pixel data.
If you need a memory stream or an array of bytes that contains a complete image, such as JPEG, you also do not need to convert it to source code. You can use the Leadtools.RasterCodecs class as follows:
RasterCodecs codecs = new RasterCodecs();
System.IO.MemoryStream memStream = new System.IO.MemoryStream();
codecs.Save(e.Image, memStream, RasterImageFormat.Jpeg, 24);
source
share