DicomIoException: Requested 132 bytes past end of fixed length stream.
2015-07-07 22:36
453 查看
今天在用DicomFile.Open(Stream s)这个接口时,遇到一个异常: DicomIoException: Requested 132 bytes past end of fixed length stream.
具体原因我们看下源码就很清楚:public bool Require(uint count, ByteSourceCallback callback, object state) {lock (_lock) {if ((_stream.Length - _stream.Position) >= count)return true;
throw new DicomIoException("Requested {0} bytes past end of fixed length stream.", count);}}
当时的Stream的Position位于流末尾,即Length-Position等于0, 因此抛出这个异常。
解决办法很简单:首先把Stream定位到DICOM的起始位置。
类似代码如下: var stream = new MemoryStream(); using (var f = File.Open(@"1.2.156.112605.75006881735343.1369658682.4.4.1.dcm", FileMode.Open)) { f.CopyTo(stream); } stream.Seek(0, SeekOrigin.Begin); var df = Dicom.DicomFile.Open(stream);
具体原因我们看下源码就很清楚:public bool Require(uint count, ByteSourceCallback callback, object state) {lock (_lock) {if ((_stream.Length - _stream.Position) >= count)return true;
throw new DicomIoException("Requested {0} bytes past end of fixed length stream.", count);}}
当时的Stream的Position位于流末尾,即Length-Position等于0, 因此抛出这个异常。
解决办法很简单:首先把Stream定位到DICOM的起始位置。
类似代码如下: var stream = new MemoryStream(); using (var f = File.Open(@"1.2.156.112605.75006881735343.1369658682.4.4.1.dcm", FileMode.Open)) { f.CopyTo(stream); } stream.Seek(0, SeekOrigin.Begin); var df = Dicom.DicomFile.Open(stream);
相关文章推荐
- Dynamics CRM 2015 Update 1 系列(7): 消息事务 - ExecuteTransactionRequest
- UI_UIScrollView/UIpageControl
- Android view中的requestLayout和invalidate方法
- IOS UITextView 提交建议反馈
- DirectUI界面编程(零)简介
- DirectUI界面编程(零)简介
- DirectUI界面编程(零)简介
- 【LeetCode】232. Implement Queue using Stacks
- Implement Queue using Stacks
- [刷题]N-Queens
- UITableViewCell动态计算高度
- Bluetooth: ATT and GATT
- Implement Queue using Stacks
- 苹果开发 笔记(45)UILabel
- 【Arduino】8地点LED数码管(3461BS)
- 关于Uedit上传图片和文件的问题
- UVALive Proving Equivalences (强连通分量,常规)
- LeetCode Implement Queue using Stacks
- sql中常用到的GUID
- poj2299 Ultra-QuickSort (树状数组+离散化)