static int _m_Resize(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UnityEngine.Texture2D gen_to_be_invoked = (UnityEngine.Texture2D)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 3 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3))
                {
                    int _width  = LuaAPI.xlua_tointeger(L, 2);
                    int _height = LuaAPI.xlua_tointeger(L, 3);

                    bool gen_ret = gen_to_be_invoked.Resize(_width, _height);
                    LuaAPI.lua_pushboolean(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 5 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && translator.Assignable <UnityEngine.TextureFormat>(L, 4) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 5))
                {
                    int _width  = LuaAPI.xlua_tointeger(L, 2);
                    int _height = LuaAPI.xlua_tointeger(L, 3);
                    UnityEngine.TextureFormat _format; translator.Get(L, 4, out _format);
                    bool _hasMipMap = LuaAPI.lua_toboolean(L, 5);

                    bool gen_ret = gen_to_be_invoked.Resize(_width, _height, _format, _hasMipMap);
                    LuaAPI.lua_pushboolean(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Texture2D.Resize!"));
        }
Example #2
0
        public override object WriteTo(object obj, System.Collections.Generic.Dictionary <long, UnityEngine.Object> objects)
        {
            obj = base.WriteTo(obj, objects);
            if (obj == null)
            {
                return(null);
            }
            UnityEngine.Texture2D o = (UnityEngine.Texture2D)obj;
            try
            {
                o.Resize(width, height);
            }
            catch
            {
            }

            return(o);
        }
Example #3
0
        /// <summary>
        /// Render the current slide of pptview.exe into a Unity Texture2D
        /// NOTE: this method will resize the texture if it's not the correct size/format
        /// </summary>
        /// <param name="texture">texture to receive pptview.exe's window pixels</param>
        public void Render(ref UnityEngine.Texture2D texture)
        {
            int width = 0, height = 0;

            if (!Render(ref lastRenderedPixels, ref width, ref height))
            {
                return;
            }

            if (texture.width != width ||
                texture.height != height ||
                texture.format != UnityEngine.TextureFormat.BGRA32)
            {
                texture.Resize(width, height, UnityEngine.TextureFormat.BGRA32, false);
            }

            // NOTE: this method is ONLY for debugging purposes. If you actually
            // need to render to a Texture2D faster you should use the new shiny
            // LoadRawTextureData(IntPtr data, int size) overload!

            texture.LoadRawTextureData(lastRenderedPixels);
            texture.Apply();
        }
Example #4
0
        public override void Resize(int width, int height)
        {
            unityTexture.Resize(width, height, UnityEngine.TextureFormat.RGBA32, false);

            colorsCache = new Color[width * height];
        }
Example #5
0
    private static void ThreadedScale(UnityEngine.Texture2D tex, int newWidth, int newHeight, bool useBilinear)
    {
        texColors = tex.GetPixels();
        newColors = new UnityEngine.Color[newWidth * newHeight];
        if (useBilinear)
        {
            ratioX = 1.0f / ((float)newWidth / (tex.width - 1));
            ratioY = 1.0f / ((float)newHeight / (tex.height - 1));
        }
        else
        {
            ratioX = ((float)tex.width) / newWidth;
            ratioY = ((float)tex.height) / newHeight;
        }
        w  = tex.width;
        w2 = newWidth;
        var cores = UnityEngine.Mathf.Min(UnityEngine.SystemInfo.processorCount, newHeight);
        var slice = newHeight / cores;

        finishCount = 0;
        if (mutex == null)
        {
            mutex = new System.Threading.Mutex(false);
        }
        if (cores > 1)
        {
            int        i = 0;
            ThreadData threadData;
            for (i = 0; i < cores - 1; i++)
            {
                threadData = new ThreadData(slice * i, slice * (i + 1));
                System.Threading.ParameterizedThreadStart ts = useBilinear ? new System.Threading.ParameterizedThreadStart(BilinearScale) : new System.Threading.ParameterizedThreadStart(PointScale);
                System.Threading.Thread thread = new System.Threading.Thread(ts);
                thread.Start(threadData);
            }
            threadData = new ThreadData(slice * i, newHeight);
            if (useBilinear)
            {
                BilinearScale(threadData);
            }
            else
            {
                PointScale(threadData);
            }
            while (finishCount < cores)
            {
                System.Threading.Thread.Sleep(1);
            }
        }
        else
        {
            ThreadData threadData = new ThreadData(0, newHeight);
            if (useBilinear)
            {
                BilinearScale(threadData);
            }
            else
            {
                PointScale(threadData);
            }
        }

        tex.Resize(newWidth, newHeight);
        tex.SetPixels(newColors);
        tex.Apply();

        texColors = null;
        newColors = null;
    }