Beispiel #1
0
        public unsafe void Multiplication(Picture tmp, string Chanel, int Alph)
        {
            double A = 1.0 - (Alph / 10.0);

            fixed(byte *Ptr = Arr)  //подвязывает участок памяти к определенному указателю
            {
                fixed(byte *Ptr2 = tmp.Arr)
                {
                    byte *wrk = Ptr, wrk2 = Ptr2;

                    if (Chanel == "R")
                    {
                        for (int i = 2; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp(*(wrk + i) * *(wrk2 + i) * A / 256, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "G")
                    {
                        for (int i = 1; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp(*(wrk + i) * *(wrk2 + i) * A / 256, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "B")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp(*(wrk + i) * *(wrk2 + i) * A / 256, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RG")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp(*(wrk + i + 2) * *(wrk2 + i + 2) * A / 256, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp(*(wrk + i + 1) * *(wrk2 + i + 1) * A / 256, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp(*(wrk + i + 2) * *(wrk2 + i + 2) * A / 256, 0, 255);
                            *(wrk + i)     = (byte)Clamp(*(wrk + i) * *(wrk2 + i) * A / 256, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "GB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i)     = (byte)Clamp(*(wrk + i) * *(wrk2 + i) * A / 256, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp(*(wrk + i + 1) * *(wrk2 + i + 1) * A / 256, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RGB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp(*(wrk + i + 2) * *(wrk2 + i + 2) * A / 256, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp(*(wrk + i + 1) * *(wrk2 + i + 1) * A / 256, 0, 255);
                            *(wrk + i)     = (byte)Clamp(*(wrk + i) * *(wrk2 + i) * A / 256, 0, 255);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public unsafe void Max(Picture tmp, string Chanel, int Alph) //максимум
        {
            double A = 1.0 - (Alph / 10.0);

            fixed(byte *Ptr = Arr)
            {
                fixed(byte *Ptr2 = tmp.Arr)
                {
                    byte *wrk = Ptr, wrk2 = Ptr2;

                    if (Chanel == "R")
                    {
                        for (int i = 2; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Math.Max(*(wrk + i), *(wrk2 + i) * A);
                        }
                    }
                    else
                    if (Chanel == "G")
                    {
                        for (int i = 1; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Math.Max(*(wrk + i), *(wrk2 + i) * A);
                        }
                    }
                    else
                    if (Chanel == "B")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Math.Max(*(wrk + i), *(wrk2 + i) * A);
                        }
                    }
                    else
                    if (Chanel == "RG")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Math.Max(*(wrk + i + 2), *(wrk2 + i + 2) * A);
                            *(wrk + i + 1) = (byte)Math.Max(*(wrk + i + 1), *(wrk2 + i + 1) * A);
                        }
                    }
                    else
                    if (Chanel == "RB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Math.Max(*(wrk + i + 2), *(wrk2 + i + 2) * A);
                            *(wrk + i)     = (byte)Math.Max(*(wrk + i), *(wrk2 + i) * A);
                        }
                    }
                    else
                    if (Chanel == "GB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i)     = (byte)Math.Max(*(wrk + i), *(wrk2 + i) * A);
                            *(wrk + i + 1) = (byte)Math.Max(*(wrk + i + 1), *(wrk2 + i + 1) * A);
                        }
                    }
                    else
                    if (Chanel == "RGB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Math.Max(*(wrk + i + 2), *(wrk2 + i + 2) * A);
                            *(wrk + i + 1) = (byte)Math.Max(*(wrk + i + 1), *(wrk2 + i + 1) * A);
                            *(wrk + i)     = (byte)Math.Max(*(wrk + i), *(wrk2 + i) * A);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public unsafe void Difference(Picture tmp, string Chanel, int Alph) //разность
        {
            double A = 1.0 - (Alph / 10.0);

            fixed(byte *Ptr = Arr)
            {
                fixed(byte *Ptr2 = tmp.Arr)
                {
                    byte *wrk = Ptr, wrk2 = Ptr2;

                    if (Chanel == "R")
                    {
                        for (int i = 2; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp(*(wrk + i) - *(wrk2 + i) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "G")
                    {
                        for (int i = 1; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp(*(wrk + i) - *(wrk2 + i) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "B")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp(*(wrk + i) - *(wrk2 + i) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RG")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp(*(wrk + i + 2) - *(wrk2 + i + 2) * A, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp(*(wrk + i + 1) - *(wrk2 + i + 1) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp(*(wrk + i + 2) - *(wrk2 + i + 2) * A, 0, 255);
                            *(wrk + i)     = (byte)Clamp(*(wrk + i) - *(wrk2 + i) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "GB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i)     = (byte)Clamp(*(wrk + i) - *(wrk2 + i) * A, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp(*(wrk + i + 1) - *(wrk2 + i + 1) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RGB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp(*(wrk + i + 2) - *(wrk2 + i + 2) * A, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp(*(wrk + i + 1) - *(wrk2 + i + 1) * A, 0, 255);
                            *(wrk + i)     = (byte)Clamp(*(wrk + i) - *(wrk2 + i) * A, 0, 255);
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public unsafe void Avg(Picture tmp, string Chanel, int Alph) //среднее арифмитическое
        {
            double A = 1.0 - (Alph / 10.0);

            fixed(byte *Ptr = Arr)
            {
                fixed(byte *Ptr2 = tmp.Arr)
                {
                    byte *wrk = Ptr, wrk2 = Ptr2;

                    if (Chanel == "R")
                    {
                        for (int i = 2; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp((*(wrk + i) + *(wrk2 + i) * A) / 2, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "G")
                    {
                        for (int i = 1; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp((*(wrk + i) + *(wrk2 + i) * A) / 2, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "B")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp((*(wrk + i) + *(wrk2 + i) * A) / 2, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RG")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp((*(wrk + i + 2) + *(wrk2 + i + 2) * A) / 2, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp((*(wrk + i + 1) + *(wrk2 + i + 1) * A) / 2, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp((*(wrk + i + 2) + *(wrk2 + i + 2) * A) / 2, 0, 255);
                            *(wrk + i)     = (byte)Clamp((*(wrk + i) + *(wrk2 + i) * A) / 2, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "GB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i)     = (byte)Clamp((*(wrk + i) + *(wrk2 + i) * A) / 2, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp((*(wrk + i + 1) + *(wrk2 + i + 1) * A) / 2, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RGB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp((*(wrk + i + 2) + *(wrk2 + i + 2) * A) / 2, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp((*(wrk + i + 1) + *(wrk2 + i + 1) * A) / 2, 0, 255);
                            *(wrk + i)     = (byte)Clamp((*(wrk + i) + *(wrk2 + i) * A) / 2, 0, 255);
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public unsafe void Summ(Picture tmp, string Chanel, int Alph)
        {
            double A = 1.0 - (Alph / 10.0);

            fixed(byte *Ptr = Arr)
            {
                fixed(byte *Ptr2 = tmp.Arr)
                {
                    byte *wrk = Ptr, wrk2 = Ptr2;

                    //+0 blue //+1 green //+2 red
                    if (Chanel == "R")
                    {
                        for (int i = 2; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp(*(wrk + i) + *(wrk2 + i) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "G")
                    {
                        for (int i = 1; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp(*(wrk + i) + *(wrk2 + i) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "B")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i) = (byte)Clamp(*(wrk + i) + *(wrk2 + i) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RG")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp(*(wrk + i + 2) + *(wrk2 + i + 2) * A, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp(*(wrk + i + 1) + *(wrk2 + i + 1) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp(*(wrk + i + 2) + *(wrk2 + i + 2) * A, 0, 255);
                            *(wrk + i)     = (byte)Clamp(*(wrk + i) + *(wrk2 + i) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "GB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i)     = (byte)Clamp(*(wrk + i) + *(wrk2 + i) * A, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp(*(wrk + i + 1) + *(wrk2 + i + 1) * A, 0, 255);
                        }
                    }
                    else
                    if (Chanel == "RGB")
                    {
                        for (int i = 0; i < Width * Height * 3; i = i + 3)
                        {
                            *(wrk + i + 2) = (byte)Clamp(*(wrk + i + 2) + *(wrk2 + i + 2) * A, 0, 255);
                            *(wrk + i + 1) = (byte)Clamp(*(wrk + i + 1) + *(wrk2 + i + 1) * A, 0, 255);
                            *(wrk + i)     = (byte)Clamp(*(wrk + i) + *(wrk2 + i) * A, 0, 255);
                        }
                    }
                }
            }
        }