Exemple #1
0
        protected override void decodeMetaDataInternal(CameraMetaData meta)
        {
            var t = mRootIFD.getEntryRecursive(TagType.ISOSPEEDRATINGS);

            if (t != null)
            {
                mRaw.metadata.isoSpeed = t.getInt();
            }

            // Set the make and model
            t = mRootIFD.getEntryRecursive(TagType.MAKE);
            var t2 = mRootIFD.getEntryRecursive(TagType.MODEL);

            if (t != null && t != null)
            {
                string make  = t.dataAsString;
                string model = t2.dataAsString;
                make  = make.Trim();
                model = model.Trim();
                mRaw.metadata.make  = make;
                mRaw.metadata.model = model;

                Camera cam = meta.getCamera(make, model, "dng");
                if (cam == null) //Also look for non-DNG cameras in case it's a converted file
                {
                    cam = meta.getCamera(make, model, "");
                }
                if (cam != null)
                {
                    mRaw.metadata.canonical_make  = cam.canonical_make;
                    mRaw.metadata.canonical_model = cam.canonical_model;
                    mRaw.metadata.canonical_alias = cam.canonical_alias;
                    mRaw.metadata.canonical_id    = cam.canonical_id;
                }
                else
                {
                    mRaw.metadata.canonical_make  = make;
                    mRaw.metadata.canonical_model = mRaw.metadata.canonical_alias = model;
                    t = mRootIFD.getEntryRecursive(TagType.UNIQUECAMERAMODEL);
                    if (t != null)
                    {
                        mRaw.metadata.canonical_id = t.dataAsString;
                    }
                    else
                    {
                        mRaw.metadata.canonical_id = make + " " + model;
                    }
                }
            }
        }
        public bool checkCameraSupported(CameraMetaData meta, string make, string model, string mode)
        {
            make  = make.Trim();
            model = model.Trim();
            mRaw.metadata.make  = make;
            mRaw.metadata.model = model;
            Camera cam = meta.getCamera(make, model, mode);

            if (cam == null)
            {
                if (mode.Length == 0)
                {
                    Debug.WriteLine("Unable to find camera in database: " + make + " " + model + " " + mode);
                }

                if (failOnUnknown)
                {
                    throw new RawDecoderException("Camera " + make + " " + model + ", mode " + mode + " not supported, and not allowed to guess. Sorry.");
                }

                // Assume the camera can be decoded, but return false, so decoders can see that we are unsure.
                return(false);
            }

            if (!cam.supported)
            {
                throw new RawDecoderException("Camera not supported (explicit). Sorry.");
            }

            if (cam.decoderVersion > decoderVersion)
            {
                throw new RawDecoderException("Camera not supported in this version. Update RawSpeed for support.");
            }

            hints = cam.hints;
            return(true);
        }
        public void setMetaData(CameraMetaData meta, string make, string model, string mode, int iso_speed)
        {
            mRaw.metadata.isoSpeed = iso_speed;
            make  = make.Trim();
            model = model.Trim();
            Camera cam = meta.getCamera(make, model, mode);

            if (cam == null)
            {
                Debug.WriteLine("ISO:" + iso_speed);
                Debug.WriteLine("Unable to find camera in database: " + make + " " + model + " " + mode + "\nPlease upload file to ftp.rawstudio.org, thanks!");
                return;
            }

            mRaw.cfa = cam.cfa;
            mRaw.metadata.canonical_make  = cam.canonical_make;
            mRaw.metadata.canonical_model = cam.canonical_model;
            mRaw.metadata.canonical_alias = cam.canonical_alias;
            mRaw.metadata.canonical_id    = cam.canonical_id;
            mRaw.metadata.make            = make;
            mRaw.metadata.model           = model;
            mRaw.metadata.mode            = mode;

            if (applyCrop)
            {
                iPoint2D new_size = cam.cropSize;

                // If crop size is negative, use relative cropping
                if (new_size.x <= 0)
                {
                    new_size.x = mRaw.dim.x - cam.cropPos.x + new_size.x;
                }

                if (new_size.y <= 0)
                {
                    new_size.y = mRaw.dim.y - cam.cropPos.y + new_size.y;
                }

                mRaw.subFrame(new iRectangle2D(cam.cropPos, new_size));


                // Shift CFA to match crop
                mRaw.UncroppedCfa = new ColorFilterArray(mRaw.cfa);
                if ((cam.cropPos.x & 1) != 0)
                {
                    mRaw.cfa.shiftLeft(0);
                }
                if ((cam.cropPos.y & 1) != 0)
                {
                    mRaw.cfa.shiftDown(0);
                }
            }

            CameraSensorInfo sensor = cam.getSensorInfo(iso_speed);

            mRaw.blackLevel = sensor.blackLevel;
            mRaw.whitePoint = (uint)sensor.whiteLevel;
            mRaw.blackAreas = cam.blackAreas;
            if (mRaw.blackAreas.Count == 0 && sensor.mBlackLevelSeparate.Count != 0)
            {
                if (mRaw.isCFA && mRaw.cfa.size.area() <= sensor.mBlackLevelSeparate.Count)
                {
                    for (UInt32 i = 0; i < mRaw.cfa.size.area(); i++)
                    {
                        mRaw.blackLevelSeparate[i] = sensor.mBlackLevelSeparate[(int)i];
                    }
                }
                else if (!mRaw.isCFA && mRaw.cpp <= sensor.mBlackLevelSeparate.Count)
                {
                    for (UInt32 i = 0; i < mRaw.cpp; i++)
                    {
                        mRaw.blackLevelSeparate[i] = sensor.mBlackLevelSeparate[(int)i];
                    }
                }
            }

            // Allow overriding individual blacklevels. Values are in CFA order
            // (the same order as the in the CFA tag)
            // A hint could be:
            // <Hint name="override_cfa_black" value="10,20,30,20"/>
            cam.hints.TryGetValue("override_cfa_black", out string value);
            if (value != null)
            {
                string rgb = value;
                var    v   = rgb.Split(',');
                if (v.Length != 4)
                {
                    mRaw.errors.Add("Expected 4 values '10,20,30,20' as values for override_cfa_black hint.");
                }
                else
                {
                    for (int i = 0; i < 4; i++)
                    {
                        mRaw.blackLevelSeparate[i] = Int32.Parse(v[i]);
                    }
                }
            }
        }