本文整理汇总了C#中DicomUncompressedPixelData.ConvertPaletteColorToRgb方法的典型用法代码示例。如果您正苦于以下问题:C# DicomUncompressedPixelData.ConvertPaletteColorToRgb方法的具体用法?C# DicomUncompressedPixelData.ConvertPaletteColorToRgb怎么用?C# DicomUncompressedPixelData.ConvertPaletteColorToRgb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DicomUncompressedPixelData
的用法示例。
在下文中一共展示了DicomUncompressedPixelData.ConvertPaletteColorToRgb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Encode
public void Encode(DicomUncompressedPixelData oldPixelData, DicomCompressedPixelData newPixelData, DicomCodecParameters parameters)
{
DicomRleCodecParameters rleParams = parameters as DicomRleCodecParameters;
if (rleParams == null)
throw new DicomCodecException("Unexpected RLE Codec parameters");
// Convert to RGB
if (oldPixelData.HasPaletteColorLut && parameters.ConvertPaletteToRGB)
{
oldPixelData.ConvertPaletteColorToRgb();
newPixelData.HasPaletteColorLut = false;
newPixelData.SamplesPerPixel = oldPixelData.SamplesPerPixel;
newPixelData.PlanarConfiguration = oldPixelData.PlanarConfiguration;
newPixelData.PhotometricInterpretation = oldPixelData.PhotometricInterpretation;
}
int pixelCount = oldPixelData.ImageWidth * oldPixelData.ImageHeight;
int numberOfSegments = oldPixelData.BytesAllocated * oldPixelData.SamplesPerPixel;
for (int i = 0; i < oldPixelData.NumberOfFrames; i++)
{
RLEEncoder encoder = new RLEEncoder();
byte[] frameData = oldPixelData.GetFrame(i);
for (int s = 0; s < numberOfSegments; s++)
{
encoder.NextSegment();
int sample = s / oldPixelData.BytesAllocated;
int sabyte = s % oldPixelData.BytesAllocated;
int pos;
int offset;
if (newPixelData.PlanarConfiguration == 0)
{
pos = sample * oldPixelData.BytesAllocated;
offset = numberOfSegments;
}
else
{
pos = sample * oldPixelData.BytesAllocated * pixelCount;
offset = oldPixelData.BytesAllocated;
}
if (rleParams.ReverseByteOrder)
pos += sabyte;
else
pos += oldPixelData.BytesAllocated - sabyte - 1;
for (int p = 0; p < pixelCount; p++)
{
if (pos >= frameData.Length)
throw new DicomCodecException("");
encoder.Encode(frameData[pos]);
pos += offset;
}
encoder.Flush();
}
encoder.MakeEvenLength();
newPixelData.AddFrameFragment(encoder.GetBuffer());
}
}