/*

This file is part of Tins IMage Viewer (timv).
Copyright (c) 2010, Martin Furter
All rights reserved.

ANY-LICENSE:
You can use this software under any license approved by the
Open Source Initiative as long as the license you choose is
compatible to the dependencies of Tins IMage Viewer (timv).

See http://www.opensource.org/licenses/ for a list of
approved licenses.

*/

#ifndef _IMAGE_INFO_H_INCLUDED_
#define _IMAGE_INFO_H_INCLUDED_

#include <gtk/gtk.h>
#include <stdint.h>

/* Some boilerplate GObject defines. 'klass' is used
 *   instead of 'class', because 'class' is a C++ keyword */

#define IMAGE_INFO_TYPE            (image_info_get_type())
#define IMAGE_INFO(obj)            (G_TYPE_CHECK_INSTANCE_CAST( (obj), IMAGE_INFO_TYPE, ImageInfo) )
#define IMAGE_INFO_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST( (klass),  IMAGE_INFO_TYPE, ImageInfoClass) )
#define IS_IMAGE_INFO(obj)         (G_TYPE_CHECK_INSTANCE_TYPE( (obj), IMAGE_INFO_TYPE) )
#define IS_IMAGE_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE( (klass),  IMAGE_INFO_TYPE) )
#define IMAGE_INFO_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS( (obj),  IMAGE_INFO_TYPE, ImageInfoClass) )

#define IMAGE_INFO_NAME	"timv"
#define IMAGE_INFO_VERSION	3

typedef struct {
	char name[4];
	uint8_t version;
	uint8_t unused1;
	uint8_t unused2;
	uint8_t unused3;
} ImageInfoHeader_t;

typedef struct {
	/* this MUST be the first member */
	GObject         parent;

	uint32_t width;
	uint32_t height;
	uint64_t mtime;
	uint8_t angle;
	uint8_t flip;
	uint16_t filenamelen;
	char* filename;
	GdkPixbuf* pixbuf;
	char savedAngle;
	char savedFlip;
	char modified;
	GdkColor bgColor;
} ImageInfo;


/* ImageInfoClass: more boilerplate GObject stuff */
typedef struct {
  GObjectClass parent_class;
} ImageInfoClass;


GType image_info_get_type();
ImageInfo* image_info_new( const char* filename, time_t mtime );
gboolean image_info_save( ImageInfo* image_info );
GdkPixbuf* image_info_get_image( ImageInfo* image_info,
		int width, int height );
gboolean image_info_rotate_or_flip( ImageInfo* image_info,
		char angle, char flip, GdkPixbuf** image );
void image_info_copy( ImageInfo* dst, ImageInfo* src );

#endif /* _IMAGE_INFO_H_INCLUDED_ */

