LaurelBridge.DCF.Examples.BitmapToDicom Namespace

DICOM Connectivity Framework V3.4
The BitmapToDicom example demonstrates how to use the DCF to create a secondary capture dataset.

Public classHistogram
A histogram class ultimately used to calculate a window center and width for monochrome images.
Public classOptions
A class for BitmapToDicom program options.
Public classProgram
An example program to demonstrate how to create a DICOM dataset from a bitmap file.
Public classRgbToMono
A class that facilitates the conversion of 24 bit RGB pixel values to monochrome.
Public classSCImage
An example SCImage class that derives from SecondaryCaptureImage.

BitmapToDicom Sample Code
public class Program
    private static readonly ILogger Logger = LogManager.GetCurrentClassLogger();

    internal static String[] Usage = new string[]
        "usage:" +
        "   BitmapToDicom -h",
        "   BitmapToDicom [-p photometric -s stored -a allocated -r representation -T tsUid ] bmpPath dcmPath",
        "Required Parameters:",
        "   bmpPath        : the path to the bitmap file",
        "   dcmPath        : the path for the DICOM output file, which is overwritten if it exists",
        "Optional Parameters:",
        "   photometric    : one of RGB, M2 (MONOCHROME2), M1 (MONOCHOME1), default=RGB",
        "   stored         : 8 for RGB, 3-16 for MONO1 or MONO2, default=8 for RGB, 12 for MONO",
        "   allocated      : 8 or 16, RGB is 8 only, default=8 for bits stored <= 8, otherwise 16",
        "   representation : one of 0 (unsigned) or 1 (signed), RGB is unsigned only, default is unsigned for MONO",
        "   tsUid          : the transfer syntax uid, default=1.2.840.10008.1.2.1 (ELE)",
        "If MONO1 or MONO2 is specified, image is converted to grayscale using the specified bit depth."

    /// <summary>
    /// Main program for BitmapToDicom.
    /// </summary>
    /// <param name="args">command line arguments</param>
    public static void Main(string[] args)
        int status = 1;
            Options options = Options.GetOptions(args, Usage);

            if (options != null)
                SCImage scImage = SCImage.LoadImage(options);
                // Modify scImage to add demographics
                scImage.Save(options.DicomPath, options.TransferSyntax);
                status = 0;
        catch (Exception e)
            status = 2;
            Logger.Error(e, "BitmapToDicom: failed: ");

        if (System.Diagnostics.Debugger.IsAttached)
            Console.Write("Press any key to continue . . . ");