I need to write an app to playback a DICOM multiframe image. Each frame is stored in JPEG format. All the frames are stored consecutively in one file. Right now, I read out each frame data and pass it to the following routine to construct a Bitmap for display:
Bitmap CreateBitmap(byte[] pixelBuffer, int frameSize)
{
Bitmap image = null;
try
{
long startTicks = DateTime.Now.Ticks;
MemoryStream pixelStream = new MemoryStream(pixelBuffer, 0, frameSize);
image = new Bitmap(pixelStream);
loadTime = DateTime.Now.Ticks - startTicks;
}
catch (Exception ex)
{
Log.LogException(ex);
}
return image;
}
During the test, everything works fine except that the performance in the above routine is not optimal. For the 800x600 frame size, the time it takes in this routine is either 0msec and 15msec (I don't know why). For the 1024x768 frame size, the time it takes is either 15msec or 31msec. My goal is to stream the image data in and playback the image (1024x768 version) in 60Hz without dropping a frame. That suggests I have to decompress the JPEG frame within 15msec constantly. So my question is what's the better way to do this?