Ejemplo n.º 1
0
        public unsafe void Mutate(MutateHandler mutateHandler)
        {
            BitmapUtil.InvokeAsLocked(this.impl_, bmpData => {
                var ptr = (byte *)bmpData.Scan0;

                void GetHandler(int x,
                                int y,
                                out byte r,
                                out byte g,
                                out byte b,
                                out byte a)
                {
                    var index = 4 * (y * bmpData.Width + x);
                    b         = ptr[index];
                    g         = ptr[index + 1];
                    r         = ptr[index + 2];
                    a         = ptr[index + 3];
                }

                void SetHandler(int x, int y, byte r, byte g, byte b, byte a)
                {
                    var index      = 4 * (y * bmpData.Width + x);
                    ptr[index]     = b;
                    ptr[index + 1] = g;
                    ptr[index + 2] = r;
                    ptr[index + 3] = a;
                }

                mutateHandler(GetHandler, SetHandler);
            });
        }
Ejemplo n.º 2
0
        public static Dictionary <string, IRequestHandler> GetRequestHandlers(IScheduler scheduler, IMemCache cache)
        {
            var helpers       = new RequestConverters(scheduler);
            var getHandler    = new GetHandler(helpers, cache, scheduler);
            var mutateHandler = new MutateHandler(helpers, cache, scheduler);

            return(new Dictionary <string, IRequestHandler>
            {
                { "get", getHandler }, { "gets", getHandler }, { "set", new SetHandler(helpers, cache) }, { "append", new AppendHandler(helpers, cache) }, { "prepend", new PrependHandler(helpers, cache) }, { "add", new AddHandler(helpers, cache) }, { "replace", new ReplaceHandler(helpers, cache) }, { "cas", new CasHandler(helpers, cache) }, { "stats", new StatsHandler() }, { "delete", new DeleteHandler(helpers, cache) }, { "flush_all", new FlushHandler(cache, scheduler) }, { "quit", new QuitHandler() }, { "exception", new ExceptionHandler() }, { "version", new VersionHandler() }, { "touch", new TouchHandler(helpers, cache) }, { "incr", mutateHandler }, { "decr", mutateHandler },
            });
        }
Ejemplo n.º 3
0
        public void Mutate(MutateHandler mutateHandler)
        {
            this.impl_.Mutate((rgbGetHandler, rgbSetHandler) => {
                void IGetHandler(int x, int y, out byte intensity)
                => rgbGetHandler(x, y, out intensity, out _, out _);

                void ISetHandler(int x, int y, byte intensity)
                => rgbSetHandler(x, y, intensity, intensity, intensity);

                mutateHandler(IGetHandler, ISetHandler);
            });
        }
Ejemplo n.º 4
0
        public void Mutate(MutateHandler mutateHandler)
        {
            this.impl_.Mutate((rgbaGetHandler, rgbaSetHandler) => {
                void IaGetHandler(int x, int y, out byte intensity, out byte alpha)
                => rgbaGetHandler(x, y, out intensity, out _, out _, out alpha);

                void IaSetHandler(int x, int y, byte intensity, byte alpha)
                => rgbaSetHandler(x, y, intensity, intensity, intensity, alpha);

                mutateHandler(IaGetHandler, IaSetHandler);
            });
        }