Sets the BulkData with a RasterImage and a quality factor.
public void SetBulkData(
RasterImage image,
int QualityFactor
)
public:
void SetBulkData(
RasterImage^ image,
Int32 QualityFactor
)
image
A RasterImage that is converted to BulkData.
QualityFactor
A value indicating the quality factor (2..255) of the BulkData.
There are four ways to modify the BulkData:
When setting the BulkData using (3) SetBulkData(RasterImage,int), a quality factor is specified from 2 to 255 where 2 is the highest quality, and 255 is the lowest quality.
using Leadtools.Dicom;
using Leadtools.Dicom.Common;
using Leadtools.Dicom.Common.Extensions;
using Leadtools;
using Leadtools.Dicom.Common.Linq.BasicDirectory;
using Leadtools.Dicom.Common.DataTypes;
using Leadtools.Codecs;
public static class SetBulkDataExample
{
public static bool MyLoadJsonBeforeElementCallback(LoadJsonBeforeElementData elementData)
{
// You can change the TransferSyntax here to any valid TransferSyntax
// Setting the TransferSyntax ElementValue to empty defaults the transfer syntax to Explicit VR Little Endian
//if (elementData.Tag == DicomTag.TransferSyntaxUID)
//{
// elementData.ElementValue = string.Empty;
//}
if (elementData.Encoding == ElementDataType.BulkData)
{
// If elementData.Encoding is ElementDataType.BulkData, then the BulkDataUri is returned in elementData.ElementValue
Console.WriteLine($"BulkDataUri: {elementData.ElementValue}");
// Set the bulk data: four ways to do it
//
string rawImagePath = Path.Combine(LEAD_VARS.ImagesDir, "image2.jpg");
string pngImagePath = Path.Combine(LEAD_VARS.ImagesDir, "PngImage.png");
// Method 1: Setting the [BulkData] property
using (FileStream fs = new FileStream(rawImagePath, FileMode.Open))
{
using (MemoryStream ms = new MemoryStream())
{
fs.CopyTo(ms);
elementData.BulkData = ms.ToArray();
}
}
// Method 2: Calling SetBulkData() with a byte array
using (FileStream fs = new FileStream(rawImagePath, FileMode.Open))
{
using (MemoryStream ms = new MemoryStream())
{
fs.CopyTo(ms);
elementData.SetBulkData(ms.ToArray());
}
}
// Method 3
// Set the bulk data using a RasterImage
using (RasterCodecs codecs = new RasterCodecs())
{
using (Leadtools.RasterImage image = codecs.Load(pngImagePath))
{
// The second argument is optional and specifies the QFactor
elementData.SetBulkData(image, 2);
}
}
// Method 4
// In this example(image2.dcm) it is raw jpeg data
// For uncompressed DICOM data, pass the raw uncompressedData
using (FileStream fs = new FileStream(rawImagePath, FileMode.Open))
{
elementData.SetBulkData(fs);
}
}
return true;
}
public static void MyLoadJson()
{
string dicomPath = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image2.dcm");
string jsonPath = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image2.json");
using (DicomDataSet dsJson = new DicomDataSet())
{
dsJson.Load(dicomPath, DicomDataSetLoadFlags.None);
dsJson.SaveJson(jsonPath, DicomDataSetSaveJsonFlags.IgnoreBinaryData);
}
using (DicomDataSet ds = new DicomDataSet())
{
ds.LoadJson(jsonPath, DicomDataSetLoadJsonFlags.None, MyLoadJsonBeforeElementCallback, null);
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Leadtools.Dicom.Common.Extensions Namespace
[SetBulkData(byte[])]:../dco/Extensions-LoadBeforeElementData-SetBulkData(byte[]).md
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document