예제 #1
0
        private void Translate(float offsetRed, float offsetGreen, float offsetBlue, float offsetOpacity, MatrixOrder order)
        {
            Korekta m = new Korekta();

            m.m_pColorMatrix[4][0] = offsetRed;
            m.m_pColorMatrix[4][1] = offsetGreen;
            m.m_pColorMatrix[4][2] = offsetBlue;
            m.m_pColorMatrix[4][3] = offsetOpacity;
            Multiply(m, order);
        }
예제 #2
0
        private void Scale(float scaleRed, float scaleGreen, float scaleBlue, float scaleOpacity, MatrixOrder order)
        {
            Korekta m = new Korekta();

            m.m_pColorMatrix[0][0] = scaleRed;
            m.m_pColorMatrix[1][1] = scaleGreen;
            m.m_pColorMatrix[2][2] = scaleBlue;
            m.m_pColorMatrix[3][3] = scaleOpacity;
            Multiply(m, order);
        }
예제 #3
0
        private void TrackBar3_ValueChanged(object sender, EventArgs e)
        {
            Korekta Korekta = new Korekta();

            Korekta.ScaleColors(TrackBarContrast.Value * 0.05f, Korekta.MatrixOrder.MatrixOrderPrepend);
            Korekta.TranslateColors(TrackBarBrightness.Value * 0.05f, Korekta.MatrixOrder.MatrixOrderAppend);
            Korekta.SetSaturation(TrackBarSaturation.Value * 0.05f, Korekta.MatrixOrder.MatrixOrderAppend);

            Bitmap pSource = global::Projekt_SW.Properties.Resources.untitled;

            pictureBox.Image = Korekta.Adjust(pSource, TrackBarGamma.Value * 0.05f);
        }
예제 #4
0
        public void SetSaturation(float saturation, MatrixOrder order)
        {
            float   satCompl  = 1.0f - saturation;
            float   satComplR = lumR * satCompl;
            float   satComplG = lumG * satCompl;
            float   satComplB = lumB * satCompl;
            Korekta m         = new Korekta(new float[5][]
            {
                new float[] { satComplR + saturation, satComplR, satComplR, 0.0f, 0.0f },
                new float[] { satComplG, satComplG + saturation, satComplG, 0.0f, 0.0f },
                new float[] { satComplB, satComplB, satComplB + saturation, 0.0f, 0.0f },
                new float[] { 0.0f, 0.0f, 0.0f, 1.0f, 0.0f },
                new float[] { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }
            }
                                            );

            Multiply(m, order);
        }
예제 #5
0
        private void Multiply(Korekta pColorMatrix, MatrixOrder order)
        {
            float[][] a;
            float[][] b;
            if (order == MatrixOrder.MatrixOrderAppend)
            {
                a = pColorMatrix.m_pColorMatrix;
                b = m_pColorMatrix;
            }
            else
            {
                a = m_pColorMatrix;
                b = pColorMatrix.m_pColorMatrix;
            }
            float[][] temp = new float[5][];
            for (int y = 0; y < 5; y++)
            {
                temp[y] = new float[4];
                for (int x = 0; x < 4; x++)
                {
                    float t = 0;
                    for (int i = 0; i < 5; i++)
                    {
                        t += b[y][i] * a[i][x];
                    }
                    temp[y][x] = t;
                }
            }
            string csTemp = "";

            for (int y = 0; y < 5; y++)
            {
                for (int x = 0; x < 4; x++)
                {
                    m_pColorMatrix[y][x] = temp[y][x];
                    csTemp += m_pColorMatrix[y][x] + ", ";
                }
                csTemp += m_pColorMatrix[y][4] + "\n";
            }
        }