Example #1
0
    void OnGUI()
    {
        GUILayout.BeginArea(new Rect(10, 10, 1100, 800));
        GUILayout.BeginHorizontal();
        GUILayout.Label(srcBmp.texture);
        GUILayout.Label(distBmp.texture);
        GUILayout.EndHorizontal();
        if (GUILayout.Button("Apply convolutionFilter"))
        {
            /*
             * convolutionFilter.apply(srcBmp, distBmp);
             * distBmp.unlock();// apply texture2D
             */
            distBmp.ApplyFilter(srcBmp, new Rectangle(0, 0, srcBmp.width, srcBmp.height), new Point(0, 0), convolutionFilter);
            distBmp.Unlock();            // apply texture2D
        }
        if (GUILayout.Button("Apply MatrixFilter"))
        {
//			Debug.Log("Apply MatrixFilter");
            distBmp.ApplyFilter(srcBmp, new Rectangle(0, 0, srcBmp.width, srcBmp.height), null, grayScaleFilter);
            distBmp.Unlock();            // apply texture2D
        }
        if (GUILayout.Button("Apply threshold"))
        {
            Color c = Color.black;
            c.a = 0;
            distBmp.Threshold(srcBmp, new Rectangle(0, 0, distBmp.width, distBmp.height), 0.5f, c, Color.white);
            distBmp.Unlock();            // apply texture2D
        }
        if (GUILayout.Button("Apply resolution"))
        {
            distBmp.ChangeResolution(srcBmp, 256 / split, 256 / split);
            distBmp.Unlock();            // apply texture2D
        }
        if (GUILayout.Button("Apply FastBlur"))
        {
            distBmp.Fastblur(srcBmp, blur);
            distBmp.Unlock();            // apply texture2D
        }
        if (GUILayout.Button("Apply ColorTransform"))
        {
//			distBmp.ColorTransform(new Rectangle(0, 0, distBmp.width, distBmp.height), new ColorTransform(-1, -1, -1, 1, 255, 255, 255, 0));
//			distBmp.Unlock();// apply texture2D

            srcBmp.ColorTransform(new Rectangle(0, 0, distBmp.width, distBmp.height), new ColorTransform(-1, -1, -1, 1, 255, 255, 255, 0));
            srcBmp.Unlock();            // apply texture2D
        }
        if (GUILayout.Button("Apply Fill"))
        {
            distBmp.FillRect(new Rectangle(0, 0, distBmp.width, distBmp.height), Color.green);
            distBmp.Unlock();            // apply texture2D
        }
        if (GUILayout.Button("Apply Fill textureBytes"))
        {
//			distBmp.FillRectTexture(new Rectangle(0,0,distBmp.width/2, distBmp.height/2), srcBmp._data, srcBmp.width, distBmp.width/2, distBmp.height/2);
//			distBmp.FillRectTexture(-100, -100, fillTexture, BitmapDataChannel.ALPHA);
            distBmp.FillRectTexture(-100, -100, fillTexture);
            distBmp.Unlock();            // apply texture2D
        }
        GUILayout.EndArea();
    }