Skip to content

Commit

Permalink
Merge pull request #59 from forderud/slice-rearrange
Browse files Browse the repository at this point in the history
Flip Y-Z plane
  • Loading branch information
Jøger Hansegård authored Feb 14, 2018
2 parents fdd6974 + 095b904 commit abea205
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions TestViewer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,29 @@ private void DrawImages (uint frame)
uint[] color_map = m_source.GetColorMap();

{
// extract center-X slize
WriteableBitmap bitmap = new WriteableBitmap(image.dims[1], image.dims[2], 96.0, 96.0, PixelFormats.Rgb24, null);
// extract center-Z slize (top-left)
WriteableBitmap bitmap = new WriteableBitmap(image.dims[0], image.dims[1], 96.0, 96.0, PixelFormats.Rgb24, null);
bitmap.Lock();
unsafe {
int x = image.dims[0] / 2;
unsafe
{
int z = image.dims[2] / 2;
for (int y = 0; y < bitmap.Height; ++y)
{
for (int z = 0; z < bitmap.Width; ++z)
for (int x = 0; x < bitmap.Width; ++x)
{
byte val = image.data[x + y * image.stride0 + z * image.stride1];
byte* pixel = (byte*)bitmap.BackBuffer + z * (bitmap.Format.BitsPerPixel / 8) + y * bitmap.BackBufferStride;
byte* pixel = (byte*)bitmap.BackBuffer + x * (bitmap.Format.BitsPerPixel / 8) + y * bitmap.BackBufferStride;
SetRGBVal(pixel, color_map[val]);
}
}
}
bitmap.AddDirtyRect(new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight));
bitmap.Unlock();

ImageYZ.Source = bitmap;
ImageXY.Source = bitmap;
}
{
// extract center-Y slize
// extract center-Y slize (top-right)
WriteableBitmap bitmap = new WriteableBitmap(image.dims[0], image.dims[2], 96.0, 96.0, PixelFormats.Rgb24, null);
bitmap.Lock();
unsafe
Expand All @@ -127,26 +128,25 @@ private void DrawImages (uint frame)
ImageXZ.Source = bitmap;
}
{
// extract center-Z slize
WriteableBitmap bitmap = new WriteableBitmap(image.dims[0], image.dims[1], 96.0, 96.0, PixelFormats.Rgb24, null);
// extract center-X slize (bottom-left)
WriteableBitmap bitmap = new WriteableBitmap(image.dims[2], image.dims[1], 96.0, 96.0, PixelFormats.Rgb24, null);
bitmap.Lock();
unsafe
{
int z = image.dims[2] / 2;
for (int y = 0; y < bitmap.Height; ++y)
unsafe {
int x = image.dims[0] / 2;
for (int z = 0; z < bitmap.Height; ++z)
{
for (int x = 0; x < bitmap.Width; ++x)
for (int y = 0; y < bitmap.Width; ++y)
{
byte val = image.data[x + y * image.stride0 + z * image.stride1];
byte* pixel = (byte*)bitmap.BackBuffer + x * (bitmap.Format.BitsPerPixel / 8) + y * bitmap.BackBufferStride;
byte* pixel = (byte*)bitmap.BackBuffer + y * (bitmap.Format.BitsPerPixel / 8) + z * bitmap.BackBufferStride;
SetRGBVal(pixel, color_map[val]);
}
}
}
bitmap.AddDirtyRect(new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight));
bitmap.Unlock();

ImageXY.Source = bitmap;
ImageYZ.Source = bitmap;
}
}

Expand Down

0 comments on commit abea205

Please sign in to comment.