static COMMAND_FUNC( wt_next ) { Data_Obj *dp; Image_File *ifp; dp=PICK_OBJ( "name of image or sequence" ); ifp=PICK_IMG_FILE(""); write_image_to_file(QSP_ARG ifp,dp); }
int main(int argc, char **argv) { const char *filename = "test.mpg"; FILE *file=NULL; int res, retval=-1; AVCodecContext *codec_context= NULL; AVFrame *frame=NULL; AVPacket pkt; uint8_t endcode[] = { 0, 0, 1, 0xb7 }; codec_context = get_codec_context(320, 240, 25); check(codec_context != NULL, "unable to obtain encoding context"); file = fopen(filename, "wb"); check(file != NULL, "could not open destination file %s", filename); frame = get_av_frame(codec_context); check(frame != NULL, "unable to allocate frame"); res = write_image_to_file(file, "source/img0.jpg", 25, frame, codec_context, &pkt); res = write_image_to_file(file, "source/img1.jpg", 50, frame, codec_context, &pkt); res = write_image_to_file(file, "source/img2.jpg", 10, frame, codec_context, &pkt); res = write_image_to_file(file, "source/img3.jpg", 10, frame, codec_context, &pkt); check(res >= 0, "failed to write image to file"); res = write_delayed_frames_to_file(file, frame, codec_context, &pkt); check(res >= 0, "failed to write delayed frames"); fwrite(endcode, 1, sizeof(endcode), file); retval = 0; error: if (file) fclose(file); if (codec_context) { avcodec_close(codec_context); av_free(codec_context); } if (frame) { av_freep(&frame->data[0]); av_free(frame); } return retval; }
int main(int arg_count, char **args) { if(arg_count == 4) { struct image input = make_image_from_file(args[1]); struct image output = make_image(input.type, input.row_count, input.column_count, input.max_value); blur_image(&input, &output, strtoul(args[3], 0, 0)); write_image_to_file(&output, args[2]); } else { fprintf(stderr, "Essaie plutôt : %s input.ppm output.ppm 10", args[0]); } }
static void x_add_frame(QSP_ARG_DECL Movie *mvip,Data_Obj *dp) { /* make sure dp & mvip have same dimensions if not 1st frame */ write_image_to_file(QSP_ARG (Image_File *)mvip->mvi_data,dp); }
static int unpack_cmd(int argc, char *argv[]) { struct option opts[toc_entries_len + 3]; char file[FILENAME_MAX], outdir[PATH_MAX] = { 0 }; toc_entry_t *toc_entry; int fflag = 0; int unpack_all = 1; int i; if (argc < 2) usage(); i = fill_common_opts(opts, required_argument); add_opt(opts, i, "force", no_argument, 'f'); add_opt(opts, ++i, "out", required_argument, 'o'); add_opt(opts, ++i, NULL, 0, 0); while (1) { int c, opt_index; c = getopt_long(argc, argv, "fo:", opts, &opt_index); if (c == -1) break; switch (c) { case OPT_TOC_ENTRY: unpack_all = 0; toc_entry = &toc_entries[opt_index]; toc_entry->action = DO_UNPACK; toc_entry->action_arg = strdup(optarg); if (toc_entry->action_arg == NULL) log_err("strdup"); break; case 'f': fflag = 1; break; case 'o': snprintf(outdir, sizeof(outdir), "%s", optarg); break; default: usage(); } } argc -= optind; argv += optind; if (argc == 0) usage(); parse_fip(argv[0], NULL); if (outdir[0] != '\0') if (chdir(outdir) == -1) log_err("chdir %s", outdir); /* Mark all images to be unpacked. */ if (unpack_all) { for (toc_entry = toc_entries; toc_entry->cmdline_name != NULL; toc_entry++) { if (toc_entry->image != NULL) { toc_entry->action = DO_UNPACK; toc_entry->action_arg = NULL; } } } /* Unpack all specified images. */ for (toc_entry = toc_entries; toc_entry->cmdline_name != NULL; toc_entry++) { if (toc_entry->action != DO_UNPACK) continue; /* Build filename. */ if (toc_entry->action_arg == NULL) snprintf(file, sizeof(file), "%s.bin", toc_entry->cmdline_name); else snprintf(file, sizeof(file), "%s", toc_entry->action_arg); if (toc_entry->image == NULL) { log_warnx("Requested image %s is not in %s", file, argv[0]); free(toc_entry->action_arg); toc_entry->action_arg = NULL; continue; } if (access(file, F_OK) != 0 || fflag) { if (verbose) log_dbgx("Unpacking %s", file); write_image_to_file(toc_entry->image, file); } else { log_warnx("File %s already exists, use --force to overwrite it", file); } free(toc_entry->action_arg); toc_entry->action_arg = NULL; } free_images(); return 0; }
static int unpack_cmd(int argc, char *argv[]) { struct option *opts = NULL; size_t nr_opts = 0; char outdir[PATH_MAX] = { 0 }; image_desc_t *desc; int fflag = 0; int unpack_all = 1; if (argc < 2) unpack_usage(); opts = fill_common_opts(opts, &nr_opts, required_argument); opts = add_opt(opts, &nr_opts, "blob", required_argument, 'b'); opts = add_opt(opts, &nr_opts, "force", no_argument, 'f'); opts = add_opt(opts, &nr_opts, "out", required_argument, 'o'); opts = add_opt(opts, &nr_opts, NULL, 0, 0); while (1) { int c, opt_index = 0; c = getopt_long(argc, argv, "b:fo:", opts, &opt_index); if (c == -1) break; switch (c) { case OPT_TOC_ENTRY: { image_desc_t *desc; desc = lookup_image_desc_from_opt(opts[opt_index].name); set_image_desc_action(desc, DO_UNPACK, optarg); unpack_all = 0; break; } case 'b': { char name[_UUID_STR_LEN + 1]; char filename[PATH_MAX] = { 0 }; uuid_t uuid = { 0 }; image_desc_t *desc; parse_blob_opt(optarg, &uuid, filename, sizeof(filename)); if (memcmp(&uuid, &uuid_null, sizeof(uuid_t)) == 0 || filename[0] == '\0') unpack_usage(); desc = lookup_image_desc_from_uuid(&uuid); if (desc == NULL) { uuid_to_str(name, sizeof(name), &uuid); desc = new_image_desc(&uuid, name, "blob"); add_image_desc(desc); } set_image_desc_action(desc, DO_UNPACK, filename); unpack_all = 0; break; } case 'f': fflag = 1; break; case 'o': snprintf(outdir, sizeof(outdir), "%s", optarg); break; default: unpack_usage(); } } argc -= optind; argv += optind; free(opts); if (argc == 0) unpack_usage(); parse_fip(argv[0], NULL); if (outdir[0] != '\0') if (chdir(outdir) == -1) log_err("chdir %s", outdir); /* Unpack all specified images. */ for (desc = image_desc_head; desc != NULL; desc = desc->next) { char file[PATH_MAX]; image_t *image = desc->image; if (!unpack_all && desc->action != DO_UNPACK) continue; /* Build filename. */ if (desc->action_arg == NULL) snprintf(file, sizeof(file), "%s.bin", desc->cmdline_name); else snprintf(file, sizeof(file), "%s", desc->action_arg); if (image == NULL) { if (!unpack_all) log_warnx("%s does not exist in %s", file, argv[0]); continue; } if (access(file, F_OK) != 0 || fflag) { if (verbose) log_dbgx("Unpacking %s", file); write_image_to_file(image, file); } else { log_warnx("File %s already exists, use --force to overwrite it", file); } } return 0; }