Logo Search packages:      
Sourcecode: zbar version File versions  Download package

int zbar_image_write ( const zbar_image_t image,
const char *  filebase 

dump raw image data to a file for debug. the data will be prefixed with a 16 byte header consisting of:

  • 4 bytes uint = 0x676d697a ("zimg")
  • 4 bytes format fourcc
  • 2 bytes width
  • 2 bytes height
  • 4 bytes size of following image data in bytes this header can be dumped w/eg:
           od -Ax -tx1z -N16 -w4 [file]
    for some formats the image can be displayed/converted using ImageMagick, eg:
           display -size 640x480+16 [-depth ?] [-sampling-factor ?x?] \

image the image object to dump
filebase base filename, appended with ".XXXX.zimg" where XXXX is the format fourcc
0 on success or a system error code on failure

Definition at line 201 of file image.c.

References zbar_image_write().

Referenced by zbar_image_write().

    int len = strlen(filebase) + 16;
    char filename[len];
    strcpy(filename, filebase);
    int n = 0;
    if(*(char*)&img->format >= ' ')
        n = snprintf(filename, len, "%s.%.4s.zimg",
                     filebase, (char*)&img->format);
        n = snprintf(filename, len, "%s.%08" PRIx32 ".zimg",
                     filebase, img->format);
    assert(n < len);
    filename[len] = '\0';

    zprintf(1, "dumping %.4s(%08" PRIx32 ") image to %s\n",
            (char*)&img->format, img->format, filename);

    FILE *f = fopen(filename, "w");
    if(!f) {
        int rc = errno;
        zprintf(1, "ERROR opening %s: %s\n", filename, strerror(rc));

    zimg_hdr_t hdr;
    hdr.magic = 0x676d697a;
    hdr.format = img->format;
    hdr.width = img->width;
    hdr.height = img->height;
    hdr.size = img->datalen;

    if(fwrite(&hdr, sizeof(hdr), 1, f) != 1 ||
       fwrite(img->data, 1, img->datalen, f) != img->datalen) {
        int rc = errno;
        zprintf(1, "ERROR writing %s: %s\n", filename, strerror(rc));

Generated by  Doxygen 1.6.0   Back to index