summaryrefslogtreecommitdiffstats
path: root/src/itdb_thumb.h
blob: 7c2806c03ede8d71ca2f6dd9ebf66826a5130551 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
|  Copyright (C) 2002-2007 Jorg Schuler <jcsjcs at users sourceforge net>
|                2007 Christophe Fergeau <teuf at gnome org>
|
|  The code contained in this file is free software; you can redistribute
|  it and/or modify it under the terms of the GNU Lesser General Public
|  License as published by the Free Software Foundation; either version
|  2.1 of the License, or (at your option) any later version.
|
|  This file is distributed in the hope that it will be useful,
|  but WITHOUT ANY WARRANTY; without even the implied warranty of
|  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
|  Lesser General Public License for more details.
|
|  You should have received a copy of the GNU Lesser General Public
|  License along with this code; if not, write to the Free Software
|  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
|
|  iTunes and iPod are trademarks of Apple
|
|  This product is not supported/written/published by Apple!
*/
#ifndef __ITDB_THUMB_H__
#define __ITDB_THUMB_H__

#include "itdb.h"
#include "itdb_device.h"

/* Types of thumbnails in Itdb_Image */
enum _ItdbThumbDataType {
    ITDB_THUMB_TYPE_INVALID,
    ITDB_THUMB_TYPE_FILE,
    ITDB_THUMB_TYPE_MEMORY,
    ITDB_THUMB_TYPE_PIXBUF,
    ITDB_THUMB_TYPE_IPOD
};
typedef enum _ItdbThumbDataType ItdbThumbDataType;

/* The Itdb_Thumb structure can represent two slightly different
   thumbnails:

  a) a thumbnail before it's transferred to the iPod.

     offset and size are 0

     width and height, if unequal 0, will indicate the size on the
     iPod. width and height are set the first time a pixbuf is
     requested for this thumbnail.

     type is set according to the type this thumbnail represents

     filename point to a 'real' image file OR image_data and
     image_data_len are set.
 
  b) a thumbnail (big or small) stored on a database in the iPod.  In
     these cases, id corresponds to the ID originally used in the
     database, filename points to a .ithmb file on the iPod
 */
struct _Itdb_Thumb {
    ItdbThumbDataType data_type;
    guint rotation;
};

struct _Itdb_Thumb_File {
    struct _Itdb_Thumb parent;
    gchar *filename;
};
typedef struct _Itdb_Thumb_File Itdb_Thumb_File;

struct _Itdb_Thumb_Memory {
    struct _Itdb_Thumb parent;
    guchar  *image_data;      /* holds the thumbnail data of
				 non-transfered thumbnails when
				 filename == NULL */
    gsize   image_data_len;   /* length of data */
};
typedef struct _Itdb_Thumb_Memory Itdb_Thumb_Memory;

struct _Itdb_Thumb_Pixbuf {
    struct _Itdb_Thumb parent;
    gpointer pixbuf;
};
typedef struct _Itdb_Thumb_Pixbuf Itdb_Thumb_Pixbuf;

struct _Itdb_Thumb_Ipod {
    struct _Itdb_Thumb parent;
    GList *thumbs;
};
typedef struct _Itdb_Thumb_Ipod Itdb_Thumb_Ipod;

struct _Itdb_Thumb_Ipod_Item {
    const Itdb_ArtworkFormat *format;
    gchar   *filename;
    guint32 offset;
    guint32 size;
    gint16  width;
    gint16  height;
    gint16  horizontal_padding;
    gint16  vertical_padding;
};
typedef struct _Itdb_Thumb_Ipod_Item Itdb_Thumb_Ipod_Item;

G_GNUC_INTERNAL Itdb_Thumb *itdb_thumb_new_from_file (const gchar *filename);
G_GNUC_INTERNAL Itdb_Thumb *itdb_thumb_new_from_data (const guchar *data,
                                                      gsize len);
G_GNUC_INTERNAL Itdb_Thumb *itdb_thumb_new_from_pixbuf (gpointer pixbuf);
G_GNUC_INTERNAL Itdb_Thumb_Ipod_Item *itdb_thumb_new_item_from_ipod (const Itdb_ArtworkFormat *format);
G_GNUC_INTERNAL Itdb_Thumb *itdb_thumb_ipod_new (void);
G_GNUC_INTERNAL void itdb_thumb_set_rotation (Itdb_Thumb *thumb,
                                              guint rotation);
G_GNUC_INTERNAL guint itdb_thumb_get_rotation (Itdb_Thumb *thumb);
G_GNUC_INTERNAL void itdb_thumb_ipod_add (Itdb_Thumb_Ipod *thumbs,
                                          Itdb_Thumb_Ipod_Item *thumb);
G_GNUC_INTERNAL const GList *itdb_thumb_ipod_get_thumbs (Itdb_Thumb_Ipod *thumbs);
G_GNUC_INTERNAL char *itdb_thumb_ipod_get_filename (Itdb_Device *device, Itdb_Thumb_Ipod_Item *thumb);
G_GNUC_INTERNAL Itdb_Thumb_Ipod_Item *itdb_thumb_ipod_get_item_by_type (Itdb_Thumb *thumbs,
                                                        const Itdb_ArtworkFormat *format);
G_GNUC_INTERNAL gpointer
itdb_thumb_ipod_item_to_pixbuf (Itdb_Device *device,
                                Itdb_Thumb_Ipod_Item *item);
#endif