public int stbtt_PackBegin(byte[] pixels, int pw, int ph, int stride_in_bytes, int padding)
        {
            var context = new stbrp_context(pw - padding, ph - padding);

            this.width           = pw;
            this.height          = ph;
            this.pixels          = new FakePtr <byte>(pixels);
            this.pack_info       = context;
            this.padding         = padding;
            this.stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw;
            this.h_oversample    = 1;
            this.v_oversample    = 1;
            this.skip_missing    = 0;
            if (pixels != null)
            {
                Array.Clear(pixels, 0, pw * ph);
            }
            return(1);
        }
Beispiel #2
0
        public Packer(int width = 256, int height = 256)
        {
            if (width <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(width));
            }

            if (height <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(height));
            }

            // Initialize the context
            var num_nodes = width;

            _context = new stbrp_context(num_nodes);

            fixed(stbrp_context *contextPtr = &_context)
            {
                stbrp_init_target(contextPtr, width, height, _context.all_nodes, num_nodes);
            }
        }