public void fillPipeConfig(MainWindow app)
 {
     config.OBLevel = (int)app.num_OBLevel.Value;
     config.OBGainCompEn = (bool)app.checkBox_OBGainComp.IsChecked;
     config.RGain = (int)(app.num_RGain.Value * 512);
     config.GGain = (int)(app.num_GGain.Value * 512);
     config.BGain = (int)(app.num_BGain.Value * 512);
     config.FlareLevel = (int)app.num_FlareLevel.Value;
     config.exposuregain = (int)app.num_exposuregain.Value;
     config.RGB_RR = (int)(app.decimal_RGB_RR.Value * 512);
     config.RGB_RG = (int)(app.decimal_RGB_RG.Value * 512);
     config.RGB_RB = (int)(app.decimal_RGB_RB.Value * 512);
     config.RGB_GR = (int)(app.decimal_RGB_GR.Value * 512);
     config.RGB_GG = (int)(app.decimal_RGB_GG.Value * 512);
     config.RGB_GB = (int)(app.decimal_RGB_GB.Value * 512);
     config.RGB_BR = (int)(app.decimal_RGB_BR.Value * 512);
     config.RGB_BG = (int)(app.decimal_RGB_BG.Value * 512);
     config.RGB_BB = (int)(app.decimal_RGB_BB.Value * 512);
     if (app.radioButton_pureRaw.IsChecked == true)
         config.endstage = (int)imagepipeline.pipestage.Raw;
     else if (app.radioButton_OpticalBlack.IsChecked == true)
         config.endstage = (int)imagepipeline.pipestage.OB;
     else if (app.radioButton_WhiteBalance.IsChecked == true)
         config.endstage = (int)imagepipeline.pipestage.WB;
     else if (app.radioButton_Demosaic.IsChecked == true)
         config.endstage = (int)imagepipeline.pipestage.DM;
     else if (app.radioButton_RGBColor.IsChecked == true)
         config.endstage = (int)imagepipeline.pipestage.RGB3x3;
     else if (app.radioButton_Tonecurve.IsChecked == true)
         config.endstage = (int)imagepipeline.pipestage.Tonecurve;
 }
        public int readRawFile(String path, ref byte[] rawData, MainWindow.ImageInfo image)
        {
            using (BinaryReader b = new BinaryReader(File.Open(path, FileMode.Open))) {
                // Position and length variables.

                // 2 bytes per pixel
                rawData = b.ReadBytes(image.rawWidth * image.rawHeight * 2);
                int temppixel = 0;

                // shift to MSB aligned according to precision
                for (int i = 0; i < image.rawWidth * image.rawHeight; i++) {
                    if (image.rawBitwidth == 10) {
                        temppixel = (rawData[i * 2 + 1] & 0x03) << 8;
                        temppixel += rawData[i * 2];
                        temppixel = temppixel << 6;
                    } else if (image.rawBitwidth == 12) {
                        temppixel = (rawData[i * 2 + 1] & 0x0f) << 8;
                        temppixel += rawData[i * 2];
                        temppixel = temppixel << 4;
                    } else if (image.rawBitwidth == 14) {
                        temppixel = (rawData[i * 2 + 1] & 0x3f) << 8;
                        temppixel += rawData[i * 2];
                        temppixel = temppixel << 2;
                    }

                    rawData[i * 2 + 1] = (byte)((temppixel & 0xff00) >> 8);
                    rawData[i * 2] = (byte)((temppixel & 0xff));
                }
            }
            return 0;
        }