SetBitmapValue example for C#
//This example uses the predefined variable “LEADRasterView1”
of type “AxLEADRasterView” from “LEADTOOLS Toolkit”.
//LEADDICOM1 is a DICOM Dataset defined outside this method
private void TestSetBitmapValue()
{
int lCount = 0;
short nRet = 0;
LTRASTERIOLib.LEADRasterIO IO = new LTRASTERIOLib.LEADRasterIO();
LEADDICOM1.EnableMethodErrors
= false;
//move to the root element
LEADDICOM1.MoveFirstElement(false);
LEADDICOM1.MoveRootElement();
//insert a new element for the Bitmap Value
nRet = LEADDICOM1.FindFirstElement((int)LTDICLib.DicomDataSetTagConstants9.TAG_PIXEL_DATA,
false);
nRet = LEADDICOM1.DeleteElement();
nRet = LEADDICOM1.InsertElement(false,
(int)LTDICLib.DicomDataSetTagConstants9.TAG_PIXEL_DATA, (short)LTDICLib.DicomVRCodeConstants.VR_OB,
false, 0);
//load an image
IO.Load(LEADRasterView1.Raster, "d:\\lead14\\dist\\images\\image1.cmp",
0, 1, 1);
MessageBox.Show("Image loaded from File - Wait");
//insert the image into the element
LEADDICOM1.Bitmap = LEADRasterView1.Raster.Bitmap;
//set the bitmap
nRet = LEADDICOM1.SetBitmapValue((int)LTDICLib.DicomImageCompressionConstants.DICOM_IMAGE_COMPRESSION_NONE,
(int)LTDICLib.DicomImagePhotometricConstants.DICOM_IMAGE_PHOTOMETRIC_RGB,
0, 0, 0);
if (nRet != 0)
{
MessageBox.Show("Error");
return;
}
MessageBox.Show("Image set to Data Set - Wait");
LEADDICOM1.Bitmap = 0;
//free the value
MessageBox.Show("Image cleared from memory - Wait");
//get the bitmap back
if (nRet == 0)
{
LEADDICOM1.GetBitmapValue(0,
0, (short)LTDICLib.DicomColorOrderConstants.ORDER_RGB, 0);
LEADRasterView1.Raster.Bitmap = LEADDICOM1.Bitmap;
LEADRasterView1.ForceRepaint();
}
LEADDICOM1.EnableMethodErrors
= true;
MessageBox.Show("Image loaded from Data Set - Wait");
}