public static void *stbi__load_gif_main(StbiContext s, int **delays, int *x, int *y, int *z, int *comp, int reqComp) { if (stbi__gif_test(s) != 0) { var layers = 0; byte *u = null; byte *out_ = null; byte *two_back = null; var g = new StbiGif(); var stride = 0; if (delays != null) { *delays = null; } do { u = stbi__gif_load_next(s, g, comp, reqComp, two_back); if (u != null) { *x = g.W; *y = g.H; ++layers; stride = g.W * g.H * 4; if (out_ != null) { out_ = (byte *)CRuntime.Realloc(out_, (ulong)(layers * stride)); if (delays != null) { *delays = (int *)CRuntime.Realloc(*delays, (ulong)(sizeof(int) * layers)); } } else { out_ = (byte *)stbi__malloc((ulong)(layers * stride)); if (delays != null) { *delays = (int *)stbi__malloc((ulong)(layers * sizeof(int))); } } CRuntime.Memcpy(out_ + (layers - 1) * stride, u, (ulong)stride); if (layers >= 2) { two_back = out_ - 2 * stride; } if (delays != null) { (*delays)[layers - 1U] = g.Delay; } } } while (u != null); CRuntime.Free(g.Out); CRuntime.Free(g.History); CRuntime.Free(g.Background); if (reqComp != 0 && reqComp != 4) { out_ = stbi__convert_format(out_, 4, reqComp, (uint)(layers * g.W), (uint)g.H); } *z = layers; return(out_); } return((byte *)(ulong)(stbi__err("not GIF") != 0 ? (byte *)null : null)); }