diff --git a/stb_image.h b/stb_image.h index 9eedabedc..1f10ab21f 100644 --- a/stb_image.h +++ b/stb_image.h @@ -4885,11 +4885,12 @@ static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint3 STBI_FREE(final); return 0; } + stbi__uint32 img_x = a->s->img_x; for (j=0; j < y; ++j) { for (i=0; i < x; ++i) { int out_y = j*yspc[p]+yorig[p]; int out_x = i*xspc[p]+xorig[p]; - memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, + memcpy(final + out_y*img_x*out_bytes + out_x*out_bytes, a->out + (j*x+i)*out_bytes, out_bytes); } }