Ejemplo n.º 1
0
    // Static void method with same signature as "Main" is always
    // file base name:
    //
    /// <summary>
    /// VTK test Main method
    /// </summary>
    public static void vtkImageDataExtraTests(string[] args)
    {
        string vtkDataDir = "";

        for (int i = 0; i < args.Length; i++)
        {
            if (args[i] == "-D")
            {
                vtkDataDir = args[i + 1];
            }
        }


        //Read in bitmap and image data
        string          bmpFile = vtkDataDir + "/Data/masonry.bmp";
        vtkImageReader2 rdr     = vtkImageReader2Factory.CreateImageReader2(bmpFile);

        rdr.SetFileName(bmpFile);
        rdr.Update();
        vtkImageData idata = rdr.GetOutput();

        System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(bmpFile);

        //get bytes before and after double conversion
        byte[]       bmpArr1 = getArrayFromBitmap(bmp);
        vtkImageData bmp1    = vtkImageData.FromImage(bmp, 3);
        Bitmap       bmp2    = bmp1.ToBitmap();

        return;

        byte[] bmpArr2 = getArrayFromBitmap(bmp2);

        //get bytes before and after double conversion
        byte[]       idataArr1 = getArrayFromImageData(idata);
        Bitmap       idata1    = idata.ToBitmap();
        vtkImageData idata2    = vtkImageData.FromImage(idata1, 3);

        byte[] idataArr2 = getArrayFromImageData(idata2);


        for (int i = 0; i < bmpArr1.Length; i++)
        {
            if (bmpArr1[i] != bmpArr2[i])
            {
                throw new Exception("ERROR: Images Not Identical!");
            }
        }
        for (int i = 0; i < idataArr2.Length; i++)
        {
            if (idataArr1[i] != idataArr2[i])
            {
                throw new Exception("ERROR: Images Not Identical!");
            }
        }
        rdr.Dispose();
        Console.Out.WriteLine("Passed");
    }