public static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes) { con->width = (int)(pw); con->height = (int)(ph); con->x = (int)(0); con->y = (int)(0); con->bottom_y = (int)(0); }
public static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes) { con->width = pw; con->height = ph; con->x = 0; con->y = 0; con->bottom_y = 0; }
public void Dispose() { if (all_nodes != null) { CRuntime.free(all_nodes); all_nodes = null; } if (extra != null) { CRuntime.free(extra); extra = null; } }
public stbrp_context(int nodesCount) { if (nodesCount <= 0) { throw new ArgumentOutOfRangeException(nameof(nodesCount)); } width = height = align = init_mode = heuristic = num_nodes = 0; active_head = free_head = null; // Allocate nodes all_nodes = (stbrp_node *)CRuntime.malloc(sizeof(stbrp_node) * nodesCount); // Allocate extras extra = (stbrp_node *)CRuntime.malloc(sizeof(stbrp_node) * 2); }
public static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) { var node = first; var x1 = x0 + width; var min_y = 0; var visited_width = 0; var waste_area = 0; min_y = 0; waste_area = 0; visited_width = 0; while (node->x < x1) { if (node->y > min_y) { waste_area += visited_width * (node->y - min_y); min_y = node->y; if (node->x < x0) { visited_width += node->next->x - x0; } else { visited_width += node->next->x - node->x; } } else { var under_width = node->next->x - node->x; if (under_width + visited_width > width) { under_width = width - visited_width; } waste_area += under_width * (min_y - node->y); visited_width += under_width; } node = node->next; } *pwaste = waste_area; return(min_y); }
public static int stbtt_PackBegin(stbtt_pack_context spc, byte *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context) { stbrp_context *context = (stbrp_context *)(CRuntime.malloc((ulong)(sizeof(stbrp_context)))); int num_nodes = (int)(pw - padding); stbrp_node * nodes = (stbrp_node *)(CRuntime.malloc((ulong)(sizeof(stbrp_node) * num_nodes))); if (((context) == (null)) || ((nodes) == (null))) { if (context != (null)) { CRuntime.free(context); } if (nodes != (null)) { CRuntime.free(nodes); } return((int)(0)); } spc.user_allocator_context = alloc_context; spc.width = (int)(pw); spc.height = (int)(ph); spc.pixels = pixels; spc.pack_info = context; spc.nodes = nodes; spc.padding = (int)(padding); spc.stride_in_bytes = (int)(stride_in_bytes != 0 ? stride_in_bytes : pw); spc.h_oversample = (uint)(1); spc.v_oversample = (uint)(1); spc.skip_missing = (int)(0); stbrp_init_target(context, (int)(pw - padding), (int)(ph - padding), nodes, (int)(num_nodes)); if ((pixels) != null) { CRuntime.memset(pixels, (int)(0), (ulong)(pw * ph)); } return((int)(1)); }
public static void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) { var i = 0; for (i = 0; i < num_nodes - 1; ++i) { nodes[i].next = &nodes[i + 1]; } nodes[i].next = null; context->init_mode = STBRP__INIT_skyline; context->heuristic = STBRP_HEURISTIC_Skyline_default; context->free_head = &nodes[0]; context->active_head = &context->extra[0]; context->width = width; context->height = height; context->num_nodes = num_nodes; stbrp_setup_allow_out_of_mem(context, 0); context->extra[0].x = 0; context->extra[0].y = 0; context->extra[0].next = &context->extra[1]; context->extra[1].x = (int)width; context->extra[1].y = 65535; context->extra[1].next = null; }
public static unsafe extern void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);