BGD_DECLARE(gdImagePtr) gdImageCreateFromGdCtx (gdIOCtxPtr in) { int sx, sy; int x, y; gdImagePtr im; /* Read the header */ im = _gdCreateFromFile (in, &sx, &sy); if (im == NULL) { goto fail1; }; /* Then the data... */ /* 2.0.12: support truecolor properly in .gd as well as in .gd2. Problem reported by Andreas Pfaller. */ if (im->trueColor) { for (y = 0; (y < sy); y++) { for (x = 0; (x < sx); x++) { int pix; if (!gdGetInt (&pix, in)) { goto fail2; } im->tpixels[y][x] = pix; } } } else { for (y = 0; (y < sy); y++) { for (x = 0; (x < sx); x++) { int ch; ch = gdGetC (in); if (ch == EOF) { goto fail2; } /* ROW-MAJOR IN GD 1.3 */ im->pixels[y][x] = ch; } } } return im; fail2: gdImageDestroy (im); fail1: return 0; }
gdImagePtr gdImageCreateFromGdCtx (gdIOCtxPtr in) { int sx, sy; int x, y; gdImagePtr im; /* Read the header */ im = _gdCreateFromFile (in, &sx, &sy); if (im == NULL) { goto fail1; }; /* Then the data... */ for (y = 0; (y < sy); y++) { for (x = 0; (x < sx); x++) { int ch; ch = gdGetC (in); if (ch == EOF) { goto fail2; } /* ROW-MAJOR IN GD 1.3 */ im->pixels[y][x] = ch; } } return im; fail2: gdImageDestroy (im); fail1: return 0; }