rem: memset(trans, 0x0, 256 * sizeof (png_byte)); trans[transparentPixel] = 0xff; png_set_tRNS(png_ptr, info_ptr, trans, 1, NULL);
add: memset(trans, 0xff, 256 * sizeof (png_byte)); trans[transparentPixel] = 0;  png_set_tRNS(png_ptr, info_ptr, trans, transparentPixel + 1, NULL);
context: writePacked(const char *filename, const frame_desc *f,		const uint8 *data) {	// information on the packed format can be found in 3do/imageint.c	uint8 *buf;	const uint8 *src, *srclineend;	uint8 *dst, *dstlineend;	uint8 **lines;	uint8 pack_type, num_pixels;	int transparentPixel;	int i;		transparentPixel = findTransparentColourPacked(filename, f, data);	buf = alloca(f->bounds.w * f->bounds.h * sizeof (uint8));	memset(buf, '\0', f->bounds.w * f->bounds.h * sizeof (uint8));	dst = buf;	src = data;	lines = alloca(f->bounds.h * sizeof (uint8 *));	for (i = 0; i < f->bounds.h; i++) {		lines[i] = dst;		srclineend = src + ((MAKE_WORD(src[1], src[0]) + 2) << 2);		dstlineend = dst + f->bounds.w;		src += 2;		while (src < srclineend) {			pack_type = PACK_TYPE(*src);			num_pixels = PACK_COUNT(*src);			src++;			switch (pack_type) {				case PACK_EOL:					while (dst != dstlineend)						*(dst++) = transparentPixel;  // rest is transparent					break;				case PACK_LITERAL:					memcpy(dst, src, num_pixels);					src += num_pixels;					dst += num_pixels;					break;				case PACK_TRANS:					memset(dst, transparentPixel, num_pixels);					dst += num_pixels;					break;				case PACK_REPEAT:					memset(dst, *src, num_pixels);					src++;					dst += num_pixels;					break;			}		}	}	if (f->flags & FLAG_X_FLIP)		flipX(lines, f->bounds.w, f->bounds.h);	{		FILE *file;		png_structp png_ptr;		png_infop info_ptr;		png_color_8 sig_bit;			png_ptr = png_create_write_struct				(PNG_LIBPNG_VER_STRING, (png_voidp) NULL /* user_error_ptr */,				NULL /* user_error_fn */, NULL /* user_warning_fn */);		if (!png_ptr) {			fprintf(stderr, "png_create_write_struct failed.\n");			exit(EXIT_FAILURE);		}			info_ptr = png_create_info_struct(png_ptr);		if (!info_ptr) {			png_destroy_write_struct(&png_ptr, (png_infopp) NULL);			fprintf(stderr, "png_create_info_struct failed.\n");			exit(EXIT_FAILURE);		}		if (setjmp(png_jmpbuf(png_ptr))) {			fprintf(stderr, "png error.\n");			png_destroy_write_struct(&png_ptr, &info_ptr);			exit(EXIT_FAILURE);		}		file = fopen(filename, "wb+");		if (file == NULL) {			fprintf(stderr, "Could not open file '%s': %s\n",					filename, strerror(errno));			png_destroy_write_struct(&png_ptr, &info_ptr);			exit(EXIT_FAILURE);		}		png_init_io(png_ptr, file);		png_set_IHDR(png_ptr, info_ptr, f->bounds.w, f->bounds.h,				8 /* bit_depth per channel */, PNG_COLOR_TYPE_PALETTE,				PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,				PNG_FILTER_TYPE_DEFAULT);		sig_bit.red = 8;		sig_bit.green = 8;		sig_bit.blue = 8;		png_set_sBIT(png_ptr, info_ptr, &sig_bit);		png_set_PLTE(png_ptr, info_ptr, palettes[f->plut], 256);		if (transparentPixel >= 0) {			png_byte trans[256];			memset(trans, 0x0, 256 * sizeof (png_byte));			trans[transparentPixel] = 0xff;			png_set_tRNS(png_ptr, info_ptr, trans, 1, NULL);		}		png_write_info(png_ptr, info_ptr);		png_write_image(png_ptr, (png_byte **) lines);		png_write_end(png_ptr, info_ptr);		png_destroy_write_struct(&png_ptr, &info_ptr);		fclose(file);	}}