int sidx;
int nc;
- GD2_DBG(php_gd_error("Reading gd2 header info\n"));
+ GD2_DBG(php_gd_error("Reading gd2 header info"));
for (i = 0; i < 4; i++) {
ch = gdGetC(in);
}
id[4] = 0;
- GD2_DBG(php_gd_error("Got file code: %s\n", id));
+ GD2_DBG(php_gd_error("Got file code: %s", id));
/* Equiv. of 'magick'. */
if (strcmp(id, GD2_ID) != 0) {
- GD2_DBG(php_gd_error("Not a valid gd2 file\n"));
+ GD2_DBG(php_gd_error("Not a valid gd2 file"));
goto fail1;
}
if (gdGetWord(vers, in) != 1) {
goto fail1;
}
- GD2_DBG(php_gd_error("Version: %d\n", *vers));
+ GD2_DBG(php_gd_error("Version: %d", *vers));
if ((*vers != 1) && (*vers != 2)) {
- GD2_DBG(php_gd_error("Bad version: %d\n", *vers));
+ GD2_DBG(php_gd_error("Bad version: %d", *vers));
goto fail1;
}
/* Image Size */
if (!gdGetWord(sx, in)) {
- GD2_DBG(php_gd_error("Could not get x-size\n"));
+ GD2_DBG(php_gd_error("Could not get x-size"));
goto fail1;
}
if (!gdGetWord(sy, in)) {
- GD2_DBG(php_gd_error("Could not get y-size\n"));
+ GD2_DBG(php_gd_error("Could not get y-size"));
goto fail1;
}
- GD2_DBG(php_gd_error("Image is %dx%d\n", *sx, *sy));
+ GD2_DBG(php_gd_error("Image is %dx%d", *sx, *sy));
/* Chunk Size (pixels, not bytes!) */
if (gdGetWord(cs, in) != 1) {
goto fail1;
}
- GD2_DBG(php_gd_error("ChunkSize: %d\n", *cs));
+ GD2_DBG(php_gd_error("ChunkSize: %d", *cs));
if ((*cs < GD2_CHUNKSIZE_MIN) || (*cs > GD2_CHUNKSIZE_MAX)) {
- GD2_DBG(php_gd_error("Bad chunk size: %d\n", *cs));
+ GD2_DBG(php_gd_error("Bad chunk size: %d", *cs));
goto fail1;
}
if (gdGetWord(fmt, in) != 1) {
goto fail1;
}
- GD2_DBG(php_gd_error("Format: %d\n", *fmt));
+ GD2_DBG(php_gd_error("Format: %d", *fmt));
if ((*fmt != GD2_FMT_RAW) && (*fmt != GD2_FMT_COMPRESSED) && (*fmt != GD2_FMT_TRUECOLOR_RAW) && (*fmt != GD2_FMT_TRUECOLOR_COMPRESSED)) {
- GD2_DBG(php_gd_error("Bad data format: %d\n", *fmt));
+ GD2_DBG(php_gd_error("Bad data format: %d", *fmt));
goto fail1;
}
if (gdGetWord(ncx, in) != 1) {
goto fail1;
}
- GD2_DBG(php_gd_error("%d Chunks Wide\n", *ncx));
+ GD2_DBG(php_gd_error("%d Chunks Wide", *ncx));
/* # of chunks high */
if (gdGetWord(ncy, in) != 1) {
goto fail1;
}
- GD2_DBG(php_gd_error("%d Chunks vertically\n", *ncy));
+ GD2_DBG(php_gd_error("%d Chunks vertically", *ncy));
if (gd2_compressed(*fmt)) {
nc = (*ncx) * (*ncy);
- GD2_DBG(php_gd_error("Reading %d chunk index entries\n", nc));
+ GD2_DBG(php_gd_error("Reading %d chunk index entries", nc));
sidx = sizeof(t_chunk_info) * nc;
if (sidx <= 0) {
goto fail1;
*chunkIdx = cidx;
}
- GD2_DBG(php_gd_error("gd2 header complete\n"));
+ GD2_DBG(php_gd_error("gd2 header complete"));
return 1;
gdImagePtr im;
if (_gd2GetHeader (in, sx, sy, cs, vers, fmt, ncx, ncy, cidx) != 1) {
- GD2_DBG(php_gd_error("Bad GD2 header\n"));
+ GD2_DBG(php_gd_error("Bad GD2 header"));
goto fail1;
}
im = gdImageCreate(*sx, *sy);
}
if (im == NULL) {
- GD2_DBG(php_gd_error("Could not create gdImage\n"));
+ GD2_DBG(php_gd_error("Could not create gdImage"));
goto fail1;
}
if (!_gdGetColors(in, im, (*vers) == 2)) {
- GD2_DBG(php_gd_error("Could not read color palette\n"));
+ GD2_DBG(php_gd_error("Could not read color palette"));
goto fail2;
}
- GD2_DBG(php_gd_error("Image palette completed: %d colours\n", im->colorsTotal));
+ GD2_DBG(php_gd_error("Image palette completed: %d colours", im->colorsTotal));
return im;
int zerr;
if (gdTell(in) != offset) {
- GD2_DBG(php_gd_error("Positioning in file to %d\n", offset));
+ GD2_DBG(php_gd_error("Positioning in file to %d", offset));
gdSeek(in, offset);
} else {
- GD2_DBG(php_gd_error("Already Positioned in file to %d\n", offset));
+ GD2_DBG(php_gd_error("Already Positioned in file to %d", offset));
}
/* Read and uncompress an entire chunk. */
- GD2_DBG(php_gd_error("Reading file\n"));
+ GD2_DBG(php_gd_error("Reading file"));
if (gdGetBuf(compBuf, compSize, in) != compSize) {
return FALSE;
}
- GD2_DBG(php_gd_error("Got %d bytes. Uncompressing into buffer of %d bytes\n", compSize, (int)*chunkLen));
+ GD2_DBG(php_gd_error("Got %d bytes. Uncompressing into buffer of %d bytes", compSize, (int)*chunkLen));
zerr = uncompress((unsigned char *) chunkBuf, chunkLen, (unsigned char *) compBuf, compSize);
if (zerr != Z_OK) {
- GD2_DBG(php_gd_error("Error %d from uncompress\n", zerr));
+ GD2_DBG(php_gd_error("Error %d from uncompress", zerr));
return FALSE;
}
- GD2_DBG(php_gd_error("Got chunk\n"));
+ GD2_DBG(php_gd_error("Got chunk"));
return TRUE;
}
chunkBuf = gdCalloc(chunkMax, 1);
compBuf = gdCalloc(compMax, 1);
- GD2_DBG(php_gd_error("Largest compressed chunk is %d bytes\n", compMax));
+ GD2_DBG(php_gd_error("Largest compressed chunk is %d bytes", compMax));
}
/* Read the data... */
yhi = im->sy;
}
- GD2_DBG(php_gd_error("Processing Chunk %d (%d, %d), y from %d to %d\n", chunkNum, cx, cy, ylo, yhi));
+ GD2_DBG(php_gd_error("Processing Chunk %d (%d, %d), y from %d to %d", chunkNum, cx, cy, ylo, yhi));
if (gd2_compressed(fmt)) {
chunkLen = chunkMax;
if (!_gd2ReadChunk(chunkIdx[chunkNum].offset, compBuf, chunkIdx[chunkNum].size, (char *) chunkBuf, &chunkLen, in)) {
- GD2_DBG(php_gd_error("Error reading comproessed chunk\n"));
+ GD2_DBG(php_gd_error("Error reading comproessed chunk"));
goto fail2;
}
}
}
- GD2_DBG(php_gd_error("Freeing memory\n"));
+ GD2_DBG(php_gd_error("Freeing memory"));
if (chunkBuf) {
gdFree(chunkBuf);
gdFree(chunkIdx);
}
- GD2_DBG(php_gd_error("Done\n"));
+ GD2_DBG(php_gd_error("Done"));
return im;
goto fail1;
}
- GD2_DBG(php_gd_error("File size is %dx%d\n", fsx, fsy));
+ GD2_DBG(php_gd_error("File size is %dx%d", fsx, fsy));
/* This is the difference - make a file based on size of chunks. */
if (gd2_truecolor(fmt)) {
if (!_gdGetColors(in, im, vers == 2)) {
goto fail2;
}
- GD2_DBG(php_gd_error("Image palette completed: %d colours\n", im->colorsTotal));
+ GD2_DBG(php_gd_error("Image palette completed: %d colours", im->colorsTotal));
/* Process the header info */
nc = ncx * ncy;
/* Remember file position of image data. */
dstart = gdTell(in);
- GD2_DBG(php_gd_error("Data starts at %d\n", dstart));
+ GD2_DBG(php_gd_error("Data starts at %d", dstart));
/* Loop through the chunks. */
for (cy = scy; (cy <= ecy); cy++) {
xhi = fsx;
}
- GD2_DBG(php_gd_error("Processing Chunk (%d, %d), from %d to %d\n", cx, cy, ylo, yhi));
+ GD2_DBG(php_gd_error("Processing Chunk (%d, %d), from %d to %d", cx, cy, ylo, yhi));
if (!gd2_compressed(fmt)) {
- GD2_DBG(php_gd_error("Using raw format data\n"));
+ GD2_DBG(php_gd_error("Using raw format data"));
if (im->trueColor) {
dpos = (cy * (cs * fsx) * 4 + cx * cs * (yhi - ylo) * 4) + dstart;
} else {
/* gd 2.0.11: gdSeek returns TRUE on success, not 0. Longstanding bug. 01/16/03 */
if (!gdSeek(in, dpos)) {
- php_gd_error_ex(E_WARNING, "Error from seek: %d\n", errno);
+ php_gd_error_ex(E_WARNING, "Error from seek: %d", errno);
goto fail2;
}
- GD2_DBG(php_gd_error("Reading (%d, %d) from position %d\n", cx, cy, dpos - dstart));
+ GD2_DBG(php_gd_error("Reading (%d, %d) from position %d", cx, cy, dpos - dstart));
} else {
chunkNum = cx + cy * ncx;
chunkLen = chunkMax;
if (!_gd2ReadChunk (chunkIdx[chunkNum].offset, compBuf, chunkIdx[chunkNum].size, chunkBuf, &chunkLen, in)) {
- php_gd_error("Error reading comproessed chunk\n");
+ php_gd_error("Error reading comproessed chunk");
goto fail2;
}
chunkPos = 0;
- GD2_DBG(php_gd_error("Reading (%d, %d) from chunk %d\n", cx, cy, chunkNum));
+ GD2_DBG(php_gd_error("Reading (%d, %d) from chunk %d", cx, cy, chunkNum));
}
- GD2_DBG(php_gd_error(" into (%d, %d) - (%d, %d)\n", xlo, ylo, xhi, yhi));
+ GD2_DBG(php_gd_error(" into (%d, %d) - (%d, %d)", xlo, ylo, xhi, yhi));
for (y = ylo; (y < yhi); y++) {
for (x = xlo; x < xhi; x++) {
*/
idxPos = gdTell(out);
idxSize = ncx * ncy * sizeof(t_chunk_info);
- GD2_DBG(php_gd_error("Index size is %d\n", idxSize));
+ GD2_DBG(php_gd_error("Index size is %d", idxSize));
gdSeek(out, idxPos + idxSize);
chunkIdx = safe_emalloc(idxSize, sizeof(t_chunk_info), 0);
_gdPutColors (im, out);
- GD2_DBG(php_gd_error("Size: %dx%d\n", im->sx, im->sy));
- GD2_DBG(php_gd_error("Chunks: %dx%d\n", ncx, ncy));
+ GD2_DBG(php_gd_error("Size: %dx%d", im->sx, im->sy));
+ GD2_DBG(php_gd_error("Chunks: %dx%d", ncx, ncy));
for (cy = 0; (cy < ncy); cy++) {
for (cx = 0; (cx < ncx); cx++) {
yhi = im->sy;
}
- GD2_DBG(php_gd_error("Processing Chunk (%dx%d), y from %d to %d\n", cx, cy, ylo, yhi));
+ GD2_DBG(php_gd_error("Processing Chunk (%dx%d), y from %d to %d", cx, cy, ylo, yhi));
chunkLen = 0;
for (y = ylo; (y < yhi); y++) {
GD2_DBG(php_gd_error("y=%d: ",y));
}
}
}
- GD2_DBG(php_gd_error("y=%d done.\n",y));
+ GD2_DBG(php_gd_error("y=%d done.",y));
}
if (gd2_compressed(fmt)) {
compLen = compMax;
if (compress((unsigned char *) &compData[0], &compLen, (unsigned char *) &chunkData[0], chunkLen) != Z_OK) {
- php_gd_error("Error from compressing\n");
+ php_gd_error("Error from compressing");
} else {
chunkIdx[chunkNum].offset = gdTell(out);
chunkIdx[chunkNum++].size = compLen;
- GD2_DBG(php_gd_error("Chunk %d size %d offset %d\n", chunkNum, chunkIdx[chunkNum - 1].size, chunkIdx[chunkNum - 1].offset));
+ GD2_DBG(php_gd_error("Chunk %d size %d offset %d", chunkNum, chunkIdx[chunkNum - 1].size, chunkIdx[chunkNum - 1].offset));
if (gdPutBuf (compData, compLen, out) <= 0) {
/* Any alternate suggestions for handling this? */
- php_gd_error_ex(E_WARNING, "Error %d on write\n", errno);
+ php_gd_error_ex(E_WARNING, "Error %d on write", errno);
}
}
}
if (gd2_compressed(fmt)) {
/* Save the position, write the index, restore position (paranoia). */
- GD2_DBG(php_gd_error("Seeking %d to write index\n", idxPos));
+ GD2_DBG(php_gd_error("Seeking %d to write index", idxPos));
posSave = gdTell(out);
gdSeek(out, idxPos);
- GD2_DBG(php_gd_error("Writing index\n"));
+ GD2_DBG(php_gd_error("Writing index"));
for (x = 0; x < chunkNum; x++) {
- GD2_DBG(php_gd_error("Chunk %d size %d offset %d\n", x, chunkIdx[x].size, chunkIdx[x].offset));
+ GD2_DBG(php_gd_error("Chunk %d size %d offset %d", x, chunkIdx[x].size, chunkIdx[x].offset));
gdPutInt(chunkIdx[x].offset, out);
gdPutInt(chunkIdx[x].size, out);
}
gdSeek(out, posSave);
}
fail:
- GD2_DBG(php_gd_error("Freeing memory\n"));
+ GD2_DBG(php_gd_error("Freeing memory"));
if (chunkData) {
gdFree(chunkData);
}
if (chunkIdx) {
gdFree(chunkIdx);
}
- GD2_DBG(php_gd_error("Done\n"));
+ GD2_DBG(php_gd_error("Done"));
}
void gdImageGd2 (gdImagePtr im, FILE * outFile, int cs, int fmt)
* been defined.
*/
- php_gd_error_ex(E_ERROR, "gd-png: fatal libpng error: %s\n", msg);
+ php_gd_error_ex(E_ERROR, "gd-png: fatal libpng error: %s", msg);
jmpbuf_ptr = png_get_error_ptr (png_ptr);
if (jmpbuf_ptr == NULL) { /* we are completely hosed now */
- php_gd_error_ex(E_ERROR, "gd-png: EXTREMELY fatal error: jmpbuf unrecoverable; terminating.\n");
+ php_gd_error_ex(E_ERROR, "gd-png: EXTREMELY fatal error: jmpbuf unrecoverable; terminating.");
}
longjmp (jmpbuf_ptr->jmpbuf, 1);
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#endif
if (png_ptr == NULL) {
- php_gd_error("gd-png error: cannot allocate libpng main struct\n");
+ php_gd_error("gd-png error: cannot allocate libpng main struct");
return NULL;
}
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
- php_gd_error("gd-png error: cannot allocate libpng info struct\n");
+ php_gd_error("gd-png error: cannot allocate libpng info struct");
png_destroy_read_struct (&png_ptr, NULL, NULL);
return NULL;
*/
#ifndef PNG_SETJMP_NOT_SUPPORTED
if (setjmp(gdPngJmpbufStruct.jmpbuf)) {
- php_gd_error("gd-png error: setjmp returns error condition\n");
+ php_gd_error("gd-png error: setjmp returns error condition");
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return NULL;
im = gdImageCreate((int) width, (int) height);
}
if (im == NULL) {
- php_gd_error("gd-png error: cannot allocate gdImage struct\n");
+ php_gd_error("gd-png error: cannot allocate gdImage struct");
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
gdFree(image_data);
gdFree(row_pointers);
case PNG_COLOR_TYPE_PALETTE:
png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
#ifdef DEBUG
- php_gd_error("gd-png color_type is palette, colors: %d\n", num_palette);
+ php_gd_error("gd-png color_type is palette, colors: %d", num_palette);
#endif /* DEBUG */
if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) {
/* gd 2.0: we support this rather thoroughly now. Grab the
case PNG_COLOR_TYPE_GRAY_ALPHA:
/* create a fake palette and check for single-shade transparency */
if ((palette = (png_colorp) gdMalloc (256 * sizeof (png_color))) == NULL) {
- php_gd_error("gd-png error: cannot allocate gray palette\n");
+ php_gd_error("gd-png error: cannot allocate gray palette");
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return NULL;
if (!im->trueColor) {
for (i = num_palette; i < gdMaxColors; ++i) {
if (!open[i]) {
- php_gd_error("gd-png warning: image data references out-of-range color index (%d)\n", i);
+ php_gd_error("gd-png warning: image data references out-of-range color index (%d)", i);
}
}
}
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#endif
if (png_ptr == NULL) {
- php_gd_error("gd-png error: cannot allocate libpng main struct\n");
+ php_gd_error("gd-png error: cannot allocate libpng main struct");
return;
}
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
- php_gd_error("gd-png error: cannot allocate libpng info struct\n");
+ php_gd_error("gd-png error: cannot allocate libpng info struct");
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
return;
#ifndef PNG_SETJMP_NOT_SUPPORTED
if (setjmp (gdPngJmpbufStruct.jmpbuf)) {
- php_gd_error("gd-png error: setjmp returns error condition\n");
+ php_gd_error("gd-png error: setjmp returns error condition");
png_destroy_write_struct (&png_ptr, &info_ptr);
return;