Skip to content

Commit

Permalink
Use ByteConverter instead of ByteBufferEnumerator. Fixes #72
Browse files Browse the repository at this point in the history
  • Loading branch information
anders9ustafsson committed Aug 13, 2015
1 parent b15b061 commit ef6a2fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions DICOM/DicomElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public IEnumerable<DicomTag> Values
if (_values == null)
{
var values = new List<DicomTag>();
var parts = ByteBufferEnumerator<ushort>.Create(Buffer).ToArray();
var parts = ByteConverter.ToArray<ushort>(Buffer);
for (int i = 0; i < parts.Length; i += 2)
{
var group = parts[i + 0];
Expand Down Expand Up @@ -965,29 +965,29 @@ public override T Get<T>(int item = -1)
{
if (!typeof(T).IsArray && item == -1) item = 0;

if (typeof(T) == typeof(short)) return (T)(object)ByteBufferEnumerator<short>.Create(Buffer).ToArray().GetValue(item);
if (typeof(T) == typeof(short)) return (T)(object)ByteConverter.Get<short>(Buffer, item);

if (typeof(T) == typeof(short[])) return (T)(object)ByteBufferEnumerator<short>.Create(Buffer).ToArray();
if (typeof(T) == typeof(short[])) return (T)(object)ByteConverter.ToArray<short>(Buffer);

if (typeof(T) == typeof(ushort)) return (T)(object)ByteBufferEnumerator<ushort>.Create(Buffer).ToArray().GetValue(item);
if (typeof(T) == typeof(ushort)) return (T)(object)ByteConverter.Get<ushort>(Buffer, item);

if (typeof(T) == typeof(ushort[])) return (T)(object)ByteBufferEnumerator<ushort>.Create(Buffer).ToArray();
if (typeof(T) == typeof(ushort[])) return (T)(object)ByteConverter.ToArray<ushort>(Buffer);

if (typeof(T) == typeof(int)) return (T)(object)ByteBufferEnumerator<int>.Create(Buffer).ToArray().GetValue(item);
if (typeof(T) == typeof(int)) return (T)(object)ByteConverter.Get<int>(Buffer, item);

if (typeof(T) == typeof(int[])) return (T)(object)ByteBufferEnumerator<int>.Create(Buffer).ToArray();
if (typeof(T) == typeof(int[])) return (T)(object)ByteConverter.ToArray<int>(Buffer);

if (typeof(T) == typeof(uint)) return (T)(object)ByteBufferEnumerator<uint>.Create(Buffer).ToArray().GetValue(item);
if (typeof(T) == typeof(uint)) return (T)(object)ByteConverter.Get<uint>(Buffer, item);

if (typeof(T) == typeof(uint[])) return (T)(object)ByteBufferEnumerator<uint>.Create(Buffer).ToArray();
if (typeof(T) == typeof(uint[])) return (T)(object)ByteConverter.ToArray<uint>(Buffer);

if (typeof(T) == typeof(float)) return (T)(object)ByteBufferEnumerator<float>.Create(Buffer).ToArray().GetValue(item);
if (typeof(T) == typeof(float)) return (T)(object)ByteConverter.Get<float>(Buffer, item);

if (typeof(T) == typeof(float[])) return (T)(object)ByteBufferEnumerator<float>.Create(Buffer).ToArray();
if (typeof(T) == typeof(float[])) return (T)(object)ByteConverter.ToArray<float>(Buffer);

if (typeof(T) == typeof(double)) return (T)(object)ByteBufferEnumerator<double>.Create(Buffer).ToArray().GetValue(item);
if (typeof(T) == typeof(double)) return (T)(object)ByteConverter.Get<double>(Buffer, item);

if (typeof(T) == typeof(double[])) return (T)(object)ByteBufferEnumerator<double>.Create(Buffer).ToArray();
if (typeof(T) == typeof(double[])) return (T)(object)ByteConverter.ToArray<double>(Buffer);

return base.Get<T>(item);
}
Expand Down
4 changes: 2 additions & 2 deletions DICOM/Imaging/DicomOverlayData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private IByteBuffer Load()

if (pixels.BitsAllocated == 8)
{
var data = ByteBufferEnumerator<byte>.Create(frame).ToArray();
var data = IO.ByteConverter.ToArray<byte>(frame);

for (int y = oy; y < oh; y++)
{
Expand All @@ -416,7 +416,7 @@ private IByteBuffer Load()
else if (pixels.BitsAllocated == 16)
{
// we don't really care if the pixel data is signed or not
var data = ByteBufferEnumerator<ushort>.Create(frame).ToArray();
var data = IO.ByteConverter.ToArray<ushort>(frame);

for (int y = oy; y < oh; y++)
{
Expand Down

0 comments on commit ef6a2fc

Please sign in to comment.