Exemplo n.º 1
0
static int M_index (lua_State *L) { /** mnotedata[n] */
  if (lua_isnumber(L, 2)) {
    ExifMnoteData *md = checkmnote_data(L);
    lua_Number n = lua_tonumber(L, 2);
    if (n < 1 || exif_mnote_data_count(md) < n) {
      lua_pushnil(L);
    } else {
      unsigned int n_ = (unsigned int)(n-1);
      lua_createtable(L, 0, 5);
      lua_pushnumber(L, exif_mnote_data_get_id(md, n_));
      lua_setfield(L, -2, "tagid");
      lua_pushstring(L, exif_mnote_data_get_name(md, n_));
      lua_setfield(L, -2, "tag");
      lua_pushstring(L, exif_mnote_data_get_title(md, n_));
      lua_setfield(L, -2, "title");
      lua_pushstring(L, exif_mnote_data_get_description(md, n_));
      lua_setfield(L, -2, "description");
      {
        char buffer[1024];
        lua_pushstring(L, exif_mnote_data_get_value(md, n_, buffer, sizeof(buffer)/sizeof(char)));
        lua_setfield(L, -2, "value");
      }
    }
    return 1;
  } else {
    lua_getmetatable(L, 1);
    lua_pushvalue(L, 2);
    lua_gettable(L, -2);
    return 1;
  }
}
Exemplo n.º 2
0
Arquivo: exif.c Projeto: 0ion9/feh
/* Show the given MakerNote tag if it exists */
void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned int maxsize)
{
  ExifMnoteData *mn = NULL; 
  int i, num;
  char buf[1024];

  if ( (d!=NULL) && (buffer!=NULL) && (maxsize > 0) )
  {
    mn = exif_data_get_mnote_data(d);
  }
  else
  {
    return;
  }
    
  if ( mn != NULL ) 
  {
    num = exif_mnote_data_count(mn);

    /* Loop through all MakerNote tags, searching for the desired one */
    for (i=0; i < num; ++i) 
    {
      D(("%d/%d %d 0x%2x %s; %s\n", i, num, exif_mnote_data_get_id(mn, i), 
        exif_mnote_data_get_id(mn, i),
        exif_mnote_data_get_name(mn,i), 
        exif_mnote_data_get_title(mn, i) ));
      
      if (exif_mnote_data_get_id(mn, i) == tag) 
      {
        if (exif_mnote_data_get_value(mn, i, buf, sizeof(buf))) 
        {
          /* Don't bother printing it if it's entirely blank */
          exif_trim_spaces(buf);
          if (*buf != '\0')
          {
             D(("%s\n", buf));
             snprintf(buffer, (size_t)maxsize, "%s: %s\n", exif_mnote_data_get_title(mn, i), buf);
          }
        }
      }
    }
  }
}
Exemplo n.º 3
0
static int
test_exif_data (ExifData *d)
{
	unsigned int i, c;
	char v[1024], *p;
	ExifMnoteData *md;

	fprintf (stdout, "Byte order: %s\n",
		exif_byte_order_get_name (exif_data_get_byte_order (d)));

	fprintf (stdout, "Parsing maker note...\n");
	md = exif_data_get_mnote_data (d);
	if (!md) {
		fprintf (stderr, "Could not parse maker note!\n");
		exif_data_unref (d);
		return 1;
	}

	fprintf (stdout, "Increasing ref-count...\n");
	exif_mnote_data_ref (md);

	fprintf (stdout, "Decreasing ref-count...\n");
	exif_mnote_data_unref (md);

	fprintf (stdout, "Counting entries...\n");
	c = exif_mnote_data_count (md);
	fprintf (stdout, "Found %i entries.\n", c);
	for (i = 0; i < c; i++) {
		fprintf (stdout, "Dumping entry number %i...\n", i);
		fprintf (stdout, "  Name: '%s'\n",
				exif_mnote_data_get_name (md, i));
		fprintf (stdout, "  Title: '%s'\n",
				exif_mnote_data_get_title (md, i));
		fprintf (stdout, "  Description: '%s'\n",
				exif_mnote_data_get_description (md, i));
		p = exif_mnote_data_get_value (md, i, v, sizeof (v));
		if (p) { fprintf (stdout, "  Value: '%s'\n", v); }
	}

	return 0;
}
Exemplo n.º 4
0
static void
exif_entry_cb (ExifEntry *entry, gpointer data)
{
	GtkTreeStore *store;
	EogExifDetails *view;
	EogExifDetailsPrivate *priv;
	ExifCategory cat;
	ExifIfd ifd = exif_entry_get_ifd (entry);
	char *path;
	char b[1024];
	const gint key = ifd << 16 | entry->tag;

	/* This should optimize away if comparision is correct */
	g_warn_if_fail (EXIF_IFD_COUNT <= G_MAXUINT16);

	view = EOG_EXIF_DETAILS (data);
	priv = view->priv;

	store = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (view)));

	/* Take the tag's IFD into account when caching their GtkTreePaths.
	 * That should fix key collisions for tags that have the same number
	 * but are stored in different IFDs. Exif tag numbers are 16-bit
	 * values so we should be able to set the high word to the IFD number.
	 */
	path = g_hash_table_lookup (priv->id_path_hash, GINT_TO_POINTER (key));

	if (path != NULL) {
		set_row_data (store,
			      path,
			      NULL,
			      exif_tag_get_name_in_ifd (entry->tag, ifd),
			      eog_exif_entry_get_value (entry, b, sizeof(b)));
	} else {

		ExifMnoteData *mnote = (entry->tag == EXIF_TAG_MAKER_NOTE ?
			exif_data_get_mnote_data (entry->parent->parent) : NULL);

		if (mnote) {
			// Supported MakerNote Found
			unsigned int i, c = exif_mnote_data_count (mnote);

			for (i = 0; i < c; i++) {
				path = g_hash_table_lookup (priv->id_path_hash_mnote, GINT_TO_POINTER (i));
				if (path != NULL) {
					set_row_data (store, path, NULL,
						exif_mnote_data_get_title (mnote, i),
						exif_mnote_data_get_value (mnote, i, b, sizeof(b)));
				} else {
					path = set_row_data (store,
							     NULL,
							     exif_categories[EXIF_CATEGORY_MAKER_NOTE].path,
							     exif_mnote_data_get_title (mnote, i),
							     exif_mnote_data_get_value (mnote, i, b, sizeof(b)));
					g_hash_table_insert (priv->id_path_hash_mnote, GINT_TO_POINTER (i), path);
				}
			}
		} else {
			cat = get_exif_category (entry);

			path = set_row_data (store,
					     NULL,
					     exif_categories[cat].path,
					     exif_tag_get_name_in_ifd (entry->tag, ifd),
					     eog_exif_entry_get_value (entry, b,
								    sizeof(b)));

			g_hash_table_insert (priv->id_path_hash,
					     GINT_TO_POINTER (key),
					     path);
		}
	}
}