/*
         *	This method is called to copy image data from the src frame to the dest frame.
         *
         *	Depending on the value of m_bEnabled, this implementation applies a binarization or
         *	copies the image data without modifying it.
         */
        public override bool Transform(IFrame src, IFrame dest)
        {
            unsafe
            {
                // Check whether the destination frame is available
                if (dest.Ptr == null)
                {
                    return(false);
                }

                // Copy the member variables to the function's stack, to protect them from being
                // overwritten by parallel calls to setThreshold() etc.
                //
                // beginParamTransfer/endParamTransfer makes sure that the values from various
                // member variables are consistent, because the user of this filter must enclose
                // writing parameter access into beginParamTransfer/endParamTransfer, too.

                BeginParameterTransfer();
                int  threshold = m_threshold;
                bool enabled   = m_bEnabled;
                EndParameterTransfer();

                byte *pIn  = src.Ptr;
                byte *pOut = dest.Ptr;

                // Check whether binarization is enabled
                if (enabled)
                {
                    // For each byte in the input buffer, check whether it is greater or
                    // equal to the threshold.
                    int bufferSize = src.FrameType.BufferSize;
                    while (bufferSize-- > 0)
                    {
                        if (*pIn++ >= threshold)
                        {
                            *pOut++ = 255;
                        }
                        else
                        {
                            *pOut++ = 0;
                        }
                    }
                }
                else
                {
                    // Binarization is disabled: Copy the image data without modifying it.
                    dest.CopyFrom(src);
                }
            }

            return(true);
        }
        /*
         *	This method is called to copy image data from the src frame to the dest frame.
         *
         *	Depending on the value of m_bEnabled, this implementation applies a binarization or
         *	copies the image data without modifying it.
         */
        public override bool Transform(IFrame src, IFrame dest)
        {
            unsafe
            {
                // Check whether the destination frame is available
                if (dest.Ptr == null)
                {
                    return(false);
                }

                // Copy the member variables to the function's stack, to protect them from being
                // overwritten by parallel calls to setThreshold() etc.
                //
                // beginParamTransfer/endParamTransfer makes sure that the values from various
                // member variables are consistent, because the user of this filter must enclose
                // writing parameter access into beginParamTransfer/endParamTransfer, too.
                BeginParameterTransfer();
                bool enabled = m_bEnabled;
                EndParameterTransfer();

                dest.CopyFrom(src);

                byte *pIn  = src.Ptr;
                byte *pOut = dest.Ptr;

                // Correction of the Hotpixel
                byte *Hotpixel;
                int   bytesPerPixel = dest.FrameType.BitsPerPixel / 8;
                if (enabled)
                {
                    int pixelsLeftX = highestWidth - dest.FrameType.Width;
                    int pixelsLeftY = highestHeight - dest.FrameType.Height;
                    int oX          = offsetX.Value;
                    int oY          = offsetY.Value;
                    if (offsetX.Value > pixelsLeftX)
                    {
                        oX = pixelsLeftX;
                    }
                    if (offsetY.Value > pixelsLeftY)
                    {
                        oY = pixelsLeftY;
                    }

                    foreach (var p in listOfCoordinates)
                    {
                        if (p.X < oX)
                        {
                            continue;
                        }
                        if (p.Y < oY)
                        {
                            continue;
                        }
                        if (p.X >= dest.FrameType.Width + oX)
                        {
                            continue;
                        }
                        if (p.Y >= dest.FrameType.Height + oY)
                        {
                            continue;
                        }

                        if (dest.FrameType.IsBottomUp)
                        {
                            Hotpixel = pOut + ((dest.FrameType.Height - 1 - (p.Y - oY)) * dest.FrameType.Width + (p.X - oX)) * bytesPerPixel;
                        }
                        else
                        {
                            Hotpixel = pOut + ((p.Y - oY) * dest.FrameType.Width + (p.X - oX)) * bytesPerPixel;
                        }
                        if (Hotpixel < pOut + dest.FrameType.BufferSize - bytesPerPixel)
                        {
                            for (int i = 0; i < bytesPerPixel; i++)
                            {
                                Hotpixel[i] = Hotpixel[i + bytesPerPixel];
                            }
                        }
                    }
                }
            }

            return(true);
        }