Lines Matching defs:sprite

21  *        {--sprite=width,height,name {[--at=x,y] {sprite.png}}}
24 * The --sprite and --add options may occur multiple times. They are executed
25 * in order. --add may refer to any sprite already read.
29 * is to combine multiple input PNG images into a single sprite; this involves
50 struct sprite {
103 sprite_op(const struct sprite *sprite, int x_offset, int y_offset,
113 * right or bottom of the sprite:
115 if ((y_offset < 0 || (unsigned)/*SAFE*/y_offset < sprite->height) &&
116 (x_offset < 0 || (unsigned)/*SAFE*/x_offset < sprite->width))
141 png_uint_16 *out_pixel = sprite->buffer +
142 ((y+y_offset) * sprite->width + (x+x_offset))*4;
188 create_sprite(struct sprite *sprite, int *argc, const char ***argv)
190 /* Read the arguments and create this sprite. The sprite buffer has already
192 * composes them onto the sprite buffer (the code in the function above)
237 sprite_op(sprite, x, y, &image, buffer);
275 /* All the sprite operations have completed successfully. Save the RGBA
278 sprite->file = tmpfile();
280 if (sprite->file != NULL)
287 save.width = sprite->width;
288 save.height = sprite->height;
293 if (png_image_write_to_stdio(&save, sprite->file, 1/*convert_to_8_bit*/,
294 sprite->buffer, 0/*row_stride*/, NULL/*colormap*/))
297 free(sprite->buffer);
298 sprite->buffer = NULL;
303 fprintf(stderr, "simpleover: write sprite %s: %s\n", sprite->name,
308 fprintf(stderr, "simpleover: sprite %s: could not allocate tmpfile: %s\n",
309 sprite->name, strerror(errno));
315 add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite,
318 /* Given a --add argument naming this sprite, perform the operations listed
320 * (x,y), which is just an offset at which to add the sprite to the
333 /* Now add the new image into the sprite data, but only if it
339 sprite->width > output->width-x ||
340 sprite->height > output->height-y)
342 fprintf(stderr, "simpleover: sprite %s @ (%d,%d) outside image\n",
343 sprite->name, x, y);
350 /* Since we know the sprite fits we can just read it into the
356 rewind(sprite->file);
358 if (png_image_begin_read_from_stdio(&in, sprite->file))
373 fprintf(stderr, "simpleover: add sprite %s: %s\n", sprite->name,
382 sprite->name, (*argv)[0]);
398 struct sprite sprites[csprites];
404 if (strncmp(argv[0], "--sprite=", 9) == 0)
415 n = sscanf(argv[0], "--sprite=%u,%u,%" str(sprite_name_chars) "s%c",
426 sprintf(sprites[nsprites].name, "sprite-%d", nsprites+1);
428 /* Allocate a buffer for the sprite and calculate the buffer
462 fprintf(stderr, "simpleover: %s: sprite too large\n", argv[0]);
468 fprintf(stderr, "simpleover: %s: invalid sprite (%u,%u)\n",
499 if (isprite < 0) /* sprite not found */
501 fprintf(stderr, "simpleover: --add='%s': sprite not found\n", name);
628 " --sprite=width,height,name {[--at=x,y] {sprite.png}}\n"
629 " Produce a transparent sprite of size (width,height) and with\n"
631 " For each sprite.png composite it using a Porter-Duff 'Over'\n"
632 " operation at offset (x,y) in the sprite (defaulting to (0,0)).\n"
633 " Input PNGs will be truncated to the area of the sprite.\n"
636 " Optionally, before output, composite a sprite, 'name', which\n"
637 " must have been previously produced using --sprite, at each\n"
638 " offset (x,y) in the output image. Each sprite must fit\n"