DicomIoException: Requested 132 bytes past end of fixed length stream.

今天在用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);

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-12-14 18:11:31

DicomIoException: Requested 132 bytes past end of fixed length stream.的相关文章

An universal algorithm design of fixed length substring locating

     An universal algorithm design of fixed length substring locating Stringlocating is a very common operation not only in the SQL design but also in theclient development tools, in which functions are also supplied to realize thelocating operation,

Bytes to be written to the stream exceed the Content-Length bytes size specified 解决方法

context.Response.ContentType = encode;               using (StreamWriter writer = new StreamWriter(context.Response.OutputStream, UTF8))    {          writer.Write(str);    } 上面代码常会报错: Bytes to be written to the stream exceed the Content-Length bytes

(转)HttpWebRequest以UTF-8编码写入内容时发生“Bytes to be written to the stream exceed the Content-Length bytes size specified.”错误

from:http://www.cnblogs.com/Gildor/archive/2010/12/13/1904060.html HttpWebRequest以UTF-8编码写入内容时发生“Bytes to be written to the stream exceed the Content-Length bytes size specified.”错误 出错代码如下: request.ContentLength = Encoding.UTF8.GetByteCount(content);

sream bytes[] img相互转换

/// <summary> /// 将 Stream 转成 byte[] /// </summary> /// <param name="stream"></param> /// <returns></returns> public static byte[] StreamToBytes(Stream stream) { byte[] bytes = new byte[stream.Length]; stream.

YASM User Manual

This document is the user manual for the Yasm assembler. It is intended as both an introduction and a general-purpose reference for all Yasm users. 1.?Introduction Yasm is a BSD-licensed assembler that is designed from the ground up to allow for mult

Snoop resynchronization mechanism to preserve read ordering

A processor employing a post-cache (LS2) buffer. Loads are stored into the LS2buffer after probing the data cache. The load/store unit snoops the loads in the LS2?buffer against snoop requests received from an external bus. If a snoop invalidate requ

File System Design Case Studies

SRC=http://www.cs.rutgers.edu/~pxk/416/notes/13-fs-studies.html Paul Krzyzanowski April 24, 2014 Introduction We've studied various approaches to file system design. Now we'll look at some real file systems to explore the approaches that were taken i

Flexible implementation of a system management mode (SMM) in a processor

A?system?management?mode?(SMM) of operating a processor includes only a basic set of hardwired hooks or mechanisms in the processor for supporting SMM. Most of SMM functionality, such as the processing actions performed when entering and exiting SMM,

Android源码-SignApk.java

1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at