Ejemplo n.º 1
0
 public static void changePreviewWB(data d)
 {
     d.metaData.wb_B = (double)d.metaData.RGBfraction[0] / (double)d.metaData.RGBfraction[1];
     d.metaData.wb_G = (double)d.metaData.RGBfraction[2] / (double)d.metaData.RGBfraction[3];
     d.metaData.wb_R = (double)d.metaData.RGBfraction[4] / (double)d.metaData.RGBfraction[5];
 }
Ejemplo n.º 2
0
        public mlvplay(String file) : this()
        {
            //
            if (io.isMLV(file) || io.isRAW(file))
            {
                //if (settings.debugLogEnabled) debugging._saveDebug("[drop] -- file " + file + " will be analyzed now.");
                importRaw = new raw();
                data importData = new data();
                importData.metaData          = new metadata();
                importData.fileData          = new filedata();
                importData.fileData.tempPath = winIO.Path.GetTempPath();

                importData.threadData           = new threaddata();
                importData.lensData             = new lensdata();
                importData.audioData            = new audiodata();
                importData.metaData.errorString = "";

                importRaw.data = importData;

                if (io.isMLV(file))
                {
                    //if (settings.debugLogEnabled) debugging._saveDebug("[drop] is MLV ");
                    importRaw.data.metaData.isMLV        = true;
                    importRaw.data.metaData.errorString += io.setFileinfoData(file, importRaw.data.fileData);
                    //if (settings.debugLogEnabled) debugging._saveDebug("[drop] FileinfoData set");
                    importRaw.data.metaData.errorString += io.createMLVBlockList(file, importRaw);
                    Blocks.mlvBlockList = Blocks.mlvBlockList.OrderBy(x => x.timestamp).ToList();
                    importRaw.data.metaData.errorString += io.getMLVAttributes(file, Blocks.mlvBlockList, importRaw);
                    //if (settings.debugLogEnabled) debugging._saveDebug("[drop] MLV Attributes and Blocklist created and sorted. Blocks: "+Blocks.mlvBlockList.Count);
                    importRaw.AUDFBlocks = null;
                    if (importRaw.data.audioData.hasAudio)
                    {
                        importRaw.AUDFBlocks = Blocks.mlvBlockList.Where(x => x.blockTag == "AUDF").ToList();
                        //if (settings.debugLogEnabled) debugging._saveDebug("[drop] hasAudio. AUDF-List created. Blocks: " + importRaw.AUDFBlocks.Count);
                    }
                    importRaw.VIDFBlocks = null;
                    importRaw.VIDFBlocks = Blocks.mlvBlockList.Where(x => x.blockTag == "VIDF").ToList();
                    //if (settings.debugLogEnabled) debugging._saveDebug("[drop] VIDF-List created. Blocks: " + importRaw.VIDFBlocks.Count);
                    importRaw.data.metaData.errorString += io.readVIDFBlockData(importRaw);
                    //if (settings.debugLogEnabled) debugging._saveDebug("[drop] VIDF-Blockdata read and created.");
                    // correct frameCount
                    importRaw.data.metaData.frames = importRaw.VIDFBlocks.Count;

                    importRaw.convert = true;
                }
                if (io.isRAW(file))
                {
                    //if (settings.debugLogEnabled) debugging._saveDebug("[drop] is RAW ");
                    importRaw.data.metaData.isMLV     = false;
                    importRaw.data.audioData.hasAudio = false;
                    importRaw.RAWBlocks = null;
                    io.setFileinfoData(file, importRaw.data.fileData);
                    //if (settings.debugLogEnabled) debugging._saveDebug("[drop] FileinfoData set");
                    io.getRAWAttributes(file, importRaw);
                    //if (settings.debugLogEnabled) debugging._saveDebug("[drop] RAW Attributes read and set.");
                    io.createRAWBlockList(file, importRaw);
                    //if (settings.debugLogEnabled) debugging._saveDebug("[drop] RAW Blocklist created and sorted. Blocks: " + importRaw.RAWBlocks.Count);

                    // then Framelist
                    importRaw.convert = true;
                }
                // save file-WB values.
                originalWB        = importRaw.data.metaData.whiteBalance;
                originalFractions = importRaw.data.metaData.RGBfraction;
                originalWBText    = "(filedata) " + originalWB + "°K | " + dng.WBpreset[importRaw.data.metaData.whiteBalanceMode];

                // save all Properties as String
                importRaw.data.metaData.propertiesString = importRaw.data.metaData.xResolution + "x" + importRaw.data.metaData.yResolution + "px || " + importRaw.data.lensData.isoValue + "ISO | " + importRaw.data.lensData.shutter + " | " + importRaw.data.metaData.fpsString + "fps";

                // set properties of the window
                this.Width       = importRaw.data.metaData.xResolution + 48;
                this.Height      = importRaw.data.metaData.yResolution + 48;
                _playback.Width  = importRaw.data.metaData.xResolution;
                _playback.Height = importRaw.data.metaData.yResolution;
                _playback.Source = null;
                this.Title       = "mlvplay " + importRaw.data.fileData.fileNameOnly;
                _wbLabel.Content = originalWBText;
                playbackTimer.Start();
            }
        }
Ejemplo n.º 3
0
        public static byte[] setDNGHeader(data Data)
        {
            // -- change data in template

            // -- xres --
            byte[] tmp_bytes = BitConverter.GetBytes(Data.metaData.xResolution);
            DNGtemplate[0x1e] = tmp_bytes[0];
            DNGtemplate[0x1f] = tmp_bytes[1];
            // -- xres to Defaultcropsize
            DNGtemplate[0x1b6a] = tmp_bytes[0];
            DNGtemplate[0x1b6b] = tmp_bytes[1];
            // -- xres to ActiveArea
            DNGtemplate[0x1d1c] = tmp_bytes[0];
            DNGtemplate[0x1d1d] = tmp_bytes[1];

            // -- yres --
            tmp_bytes         = BitConverter.GetBytes(Data.metaData.yResolution);
            DNGtemplate[0x2a] = tmp_bytes[0];
            DNGtemplate[0x2b] = tmp_bytes[1];
            // -- yres to Rows per Strip
            DNGtemplate[0x96] = tmp_bytes[0];
            DNGtemplate[0x97] = tmp_bytes[1];
            // -- yres to Defaultcropsize
            DNGtemplate[0x1b72] = tmp_bytes[0];
            DNGtemplate[0x1b73] = tmp_bytes[1];
            // -- yres to ActiveArea
            DNGtemplate[0x1d18] = tmp_bytes[0];
            DNGtemplate[0x1d19] = tmp_bytes[1];

            // -- stripByteCounts --
            tmp_bytes         = BitConverter.GetBytes(Data.metaData.stripByteCountReal / Data.metaData.bitsperSample * Data.metaData.bitsperSampleChanged);
            DNGtemplate[0xa2] = tmp_bytes[0];
            DNGtemplate[0xa3] = tmp_bytes[1];
            DNGtemplate[0xa4] = tmp_bytes[2];
            DNGtemplate[0xa5] = tmp_bytes[3];

            // -- Default CropOrigin to Zero--
            DNGtemplate[0x1b5a] = 0;
            DNGtemplate[0x1b5b] = 0;
            DNGtemplate[0x1b62] = 0;
            DNGtemplate[0x1b63] = 0;

            // -- Blacklevel change
            DNGtemplate[0x138] = 04;
            // manual set of blacklevel
            tmp_bytes          = BitConverter.GetBytes(Data.metaData.blackLevelNew);
            DNGtemplate[0x13e] = tmp_bytes[0];
            DNGtemplate[0x13f] = tmp_bytes[1];

            // -- Whitelevel change
            DNGtemplate[0x144] = 04;
            tmp_bytes          = BitConverter.GetBytes(Data.metaData.whiteLevelNew);
            DNGtemplate[0x14a] = tmp_bytes[0];
            DNGtemplate[0x14b] = tmp_bytes[1];


            //Bits per Sample = 10 12 14 or 16
            DNGtemplate[0x36] = (byte)Data.metaData.bitsperSampleChanged;
            DNGtemplate[0x37] = 0;

            // Whitebalance from MLV/RAW/CR2 - c627 and c628
            if (Data.metaData.whiteBalance != 0)
            {
                // RGGBValues
                // -- first. erase values

                // R
                Array.Copy(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, 0, DNGtemplate, 0x1cb2, 8);

                // G
                Array.Copy(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, 0, DNGtemplate, 0x1cba, 8);

                // B
                Array.Copy(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, 0, DNGtemplate, 0x1cc2, 8);

                // now set new Values

                // R
                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[0]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cb2, 2);

                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[1]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cb6, 2);

                // G
                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[2]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cba, 2);

                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[3]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cbe, 2);

                // B
                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[4]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cc2, 2);

                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[5]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cc6, 2);
            }
            if (Data.metaData.photoRAW == true)
            {
                // RGGBValues
                // -- first. erase values

                // R
                Array.Copy(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, 0, DNGtemplate, 0x1cb2, 8);

                // G
                Array.Copy(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, 0, DNGtemplate, 0x1cba, 8);

                // B
                Array.Copy(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, 0, DNGtemplate, 0x1cc2, 8);

                // now set new Values

                // R
                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[0]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cb2, 2);

                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[1]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cb6, 2);

                // G
                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[2]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cba, 2);

                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[3]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cbe, 2);

                // B
                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[4]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cc2, 2);

                tmp_bytes = BitConverter.GetBytes(Data.metaData.RGBfraction[5]);
                Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1cc6, 2);
            }

            // colormatrixA
            Data.metaData.colorMatrixA.CopyTo(DNGtemplate, 0x1b7a);
            // colormatrixB
            Data.metaData.colorMatrixB.CopyTo(DNGtemplate, 0x1bc2);
            // forwardmatrixA
            Data.metaData.forwardMatrixA.CopyTo(DNGtemplate, 0x1d20);
            // forwardmatrixB
            Data.metaData.forwardMatrixB.CopyTo(DNGtemplate, 0x1d68);

            // REELNAME
            byte[] reelNameArray = System.Text.Encoding.UTF8.GetBytes(Data.fileData.fileNameShort);
            reelNameArray.CopyTo(DNGtemplate, 0x1db0);

            //UniqueName length
            if (Data.metaData.modell.Length > 36)
            {
                Data.metaData.modell = Data.metaData.modell.Substring(0, 36);
            }
            DNGtemplate[0x62]  = (byte)(Data.metaData.modell.Length + 1);
            DNGtemplate[0x10a] = (byte)(Data.metaData.modell.Length + 1);

            //UniqueName
            byte[] modellNameA = new Byte[36];
            for (var i = 0; i < modellNameA.Length; i++)
            {
                modellNameA[i] = 0;
            }
            System.Text.Encoding.UTF8.GetBytes(Data.metaData.modell).CopyTo(modellNameA, 0);
            modellNameA.CopyTo(DNGtemplate, 0x1dcc);
            modellNameA.CopyTo(DNGtemplate, 0x1dfc);

            // framerate
            DNGtemplate[0x270] = 0x0a; //instead 05 -> 0a
            tmp_bytes          = BitConverter.GetBytes(Data.metaData.fpsNom);
            Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1dc2, 4);

            tmp_bytes = BitConverter.GetBytes(Data.metaData.fpsDen);
            Array.Copy(tmp_bytes, 0, DNGtemplate, 0x1dc6, 4);

            //camID as serialNumber
            byte[] serial = new Byte[13];
            for (var i = 0; i < serial.Length; i++)
            {
                serial[i] = 0;
            }
            System.Text.Encoding.ASCII.GetBytes(Data.metaData.camId).CopyTo(serial, 0);
            serial.CopyTo(DNGtemplate, 0x1cea);

            return(DNGtemplate);
        }