~ubuntu-branches/ubuntu/vivid/gdk-pixbuf/vivid

« back to all changes in this revision

Viewing changes to gdk-pixbuf/testpixbuf.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2004-10-06 22:10:04 UTC
  • Revision ID: james.westby@ubuntu.com-20041006221004-rma9deknj8qctu67
Tags: upstream-0.22.0
ImportĀ upstreamĀ versionĀ 0.22.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* testpixbuf -- test program for gdk-pixbuf code
 
2
 * Copyright (C) 1999 Mark Crichton, Larry Ewing
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Library General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Library General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Library General Public
 
15
 * License along with this library; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 * Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
#include <config.h>
 
21
#include <stdio.h>
 
22
#include <stdlib.h>
 
23
#include <unistd.h>
 
24
#include <string.h>
 
25
#include <gtk/gtk.h>
 
26
#include "gdk-pixbuf.h"
 
27
#include "gdk-pixbuf-loader.h"
 
28
 
 
29
typedef struct {
 
30
        FILE             *imagefile;
 
31
        GdkPixbufLoader  *loader;
 
32
        GtkWidget        **rgbwin;
 
33
        guchar           *buf;
 
34
        guint            timeout;
 
35
        guint            readlen;
 
36
} ProgressFileStatus;
 
37
 
 
38
 
 
39
#define DEFAULT_WIDTH  24
 
40
#define DEFAULT_HEIGHT 24
 
41
 
 
42
static const unsigned char default_image[] = {
 
43
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
44
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
45
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
46
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
47
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
48
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
49
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
50
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
51
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
52
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
53
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
54
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
55
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
56
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
57
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
58
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
59
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
60
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
61
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
62
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
63
        0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 
64
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
 
65
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
66
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
67
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
68
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
 
69
        0x00, 0x00, 0x00, 0xae, 0xb3, 0xb3, 0xc6, 0xc9, 0xcd, 0xd7, 0xd4, 0xdf,
 
70
        0xec, 0xde, 0xf3, 0xe7, 0xcb, 0xe9, 0xd9, 0xb5, 0xd3, 0x00, 0x00, 0x00,
 
71
        0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
72
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
73
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
74
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xb1, 0xb7, 0xa5,
 
75
        0xb0, 0xb8, 0xad, 0xb3, 0xb9, 0xb6, 0xc1, 0xc6, 0xc8, 0xd5, 0xd3, 0xdc,
 
76
        0xec, 0xde, 0xf3, 0xe5, 0xca, 0xe6, 0xe0, 0xbb, 0xd7, 0xe1, 0xad, 0xc2,
 
77
        0xe3, 0xac, 0xa3, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
78
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
79
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
80
        0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xca, 0xc1, 0xa4, 0xc5, 0xc7, 0xac,
 
81
        0xb7, 0xbe, 0xaf, 0xad, 0xb4, 0xaf, 0xbd, 0xc2, 0xc3, 0xd1, 0xd0, 0xd8,
 
82
        0xec, 0xde, 0xf3, 0xe5, 0xc7, 0xe4, 0xe0, 0xb6, 0xd1, 0xe7, 0xa9, 0xb4,
 
83
        0xed, 0xcd, 0xb6, 0xd6, 0xcf, 0xae, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
 
84
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
85
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
86
        0x00, 0x00, 0x00, 0xdf, 0xa7, 0x9f, 0xdd, 0xbf, 0xaa, 0xcf, 0xc5, 0xa9,
 
87
        0xc1, 0xc4, 0xac, 0xb2, 0xba, 0xaf, 0xb6, 0xbb, 0xbb, 0xcd, 0xce, 0xd4,
 
88
        0xec, 0xde, 0xf3, 0xe4, 0xc4, 0xe1, 0xe0, 0xaf, 0xc7, 0xea, 0xbc, 0xae,
 
89
        0xe1, 0xd6, 0xb6, 0xc7, 0xcc, 0xae, 0xa2, 0xab, 0x9a, 0x00, 0x00, 0x00,
 
90
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
91
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
92
        0x00, 0x00, 0x00, 0xe3, 0xab, 0xc0, 0xe6, 0xa3, 0xa7, 0xdf, 0xba, 0xa8,
 
93
        0xcf, 0xc5, 0xa9, 0xbd, 0xc2, 0xae, 0xad, 0xb4, 0xaf, 0xc6, 0xc9, 0xcd,
 
94
        0xec, 0xde, 0xf3, 0xe2, 0xbf, 0xdc, 0xe7, 0xa9, 0xb4, 0xe7, 0xd6, 0xb8,
 
95
        0xc7, 0xcc, 0xae, 0xac, 0xb6, 0xa6, 0x9d, 0xa8, 0x9f, 0x00, 0x00, 0x00,
 
96
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
97
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
 
98
        0xd9, 0xaf, 0xcf, 0xe1, 0xb4, 0xd2, 0xe2, 0xb0, 0xcb, 0xe4, 0xa9, 0xbb,
 
99
        0xe2, 0xb2, 0xa6, 0xcf, 0xc5, 0xa9, 0x6a, 0x6a, 0x6a, 0x0d, 0x0d, 0x0d,
 
100
        0x0d, 0x0d, 0x0d, 0x6a, 0x6a, 0x6a, 0xed, 0xcd, 0xb6, 0xc7, 0xcc, 0xae,
 
101
        0xa6, 0xb1, 0xa3, 0x98, 0xa2, 0x9c, 0x8f, 0x97, 0x96, 0x7e, 0x84, 0x85,
 
102
        0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
103
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
 
104
        0xe8, 0xc6, 0xe7, 0xe5, 0xc2, 0xe3, 0xe3, 0xbd, 0xdd, 0xe1, 0xb6, 0xd5,
 
105
        0xe2, 0xb0, 0xcb, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
 
106
        0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x6a, 0x6a, 0x6a, 0x9d, 0xa8, 0x9f,
 
107
        0x8f, 0x97, 0x96, 0x8b, 0x90, 0x92, 0x97, 0x9e, 0xa2, 0xa0, 0xa7, 0xae,
 
108
        0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
109
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
 
110
        0xe7, 0xd3, 0xed, 0xe8, 0xd1, 0xed, 0xe8, 0xce, 0xec, 0xe9, 0xcc, 0xeb,
 
111
        0xe8, 0xc6, 0xe7, 0x0d, 0x0d, 0x0d, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
112
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x0d, 0x0d, 0x0d, 0x97, 0x9e, 0xa2,
 
113
        0xa7, 0xae, 0xb7, 0xb2, 0xb6, 0xc5, 0xba, 0xbc, 0xce, 0xbf, 0xbe, 0xd3,
 
114
        0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
115
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
 
116
        0xe9, 0xdf, 0xf0, 0xe9, 0xdf, 0xf0, 0xe9, 0xdf, 0xf0, 0xe9, 0xdf, 0xf0,
 
117
        0xe9, 0xdf, 0xf0, 0x0d, 0x0d, 0x0d, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
118
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x0d, 0x0d, 0x0d, 0xe1, 0xd2, 0xf7,
 
119
        0xe1, 0xd2, 0xf7, 0xe1, 0xd2, 0xf7, 0xe1, 0xd2, 0xf7, 0xe1, 0xd2, 0xf7,
 
120
        0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
121
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
 
122
        0xca, 0xc7, 0xd2, 0xc5, 0xc4, 0xcd, 0xbf, 0xbf, 0xc7, 0xb8, 0xb9, 0xc0,
 
123
        0xae, 0xaf, 0xb6, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
 
124
        0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x6a, 0x6a, 0x6a, 0xd5, 0xa8, 0xe1,
 
125
        0xd8, 0xb2, 0xe9, 0xd9, 0xb8, 0xed, 0xdb, 0xbd, 0xf0, 0xdc, 0xbf, 0xf1,
 
126
        0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
127
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
 
128
        0xa4, 0xa6, 0xac, 0xa8, 0xaa, 0xaf, 0xa0, 0xa6, 0xa8, 0x98, 0x9e, 0x9c,
 
129
        0xa1, 0xa8, 0x9e, 0xb1, 0xb6, 0xa1, 0x6a, 0x6a, 0x6a, 0x0d, 0x0d, 0x0d,
 
130
        0x0d, 0x0d, 0x0d, 0x6a, 0x6a, 0x6a, 0xc0, 0x8c, 0xad, 0xcc, 0x90, 0xb5,
 
131
        0xd3, 0x94, 0xca, 0xd6, 0xa2, 0xdb, 0xd5, 0xa8, 0xe1, 0xcf, 0xa7, 0xdf,
 
132
        0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
133
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
134
        0x00, 0x00, 0x00, 0x98, 0x9f, 0x9b, 0xa1, 0xa8, 0x9e, 0xac, 0xb3, 0xa0,
 
135
        0xb9, 0xb9, 0xa4, 0xd0, 0xb8, 0xa8, 0xc5, 0xb5, 0xb8, 0xb6, 0xbb, 0xad,
 
136
        0xe3, 0xd7, 0xb5, 0xdd, 0xb4, 0xa9, 0xcb, 0x89, 0xac, 0xc0, 0x8c, 0xad,
 
137
        0xc8, 0x91, 0xb5, 0xd1, 0x8d, 0xb7, 0xd3, 0x94, 0xca, 0x00, 0x00, 0x00,
 
138
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
139
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
140
        0x00, 0x00, 0x00, 0xa1, 0xa7, 0x98, 0xb1, 0xb6, 0xa1, 0xbd, 0xb9, 0xa5,
 
141
        0xd0, 0xb8, 0xa8, 0xca, 0xb5, 0xb7, 0xb8, 0xb1, 0xb1, 0xc2, 0xc8, 0xb2,
 
142
        0xe3, 0xd7, 0xb5, 0xe1, 0xbf, 0xaf, 0xdb, 0x92, 0x9a, 0xbe, 0x82, 0xa6,
 
143
        0xc0, 0x8c, 0xad, 0xc8, 0x91, 0xb4, 0xc7, 0x8b, 0xb0, 0x00, 0x00, 0x00,
 
144
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
145
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
146
        0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xbc, 0xb6, 0xa1, 0xd0, 0xb8, 0xa8,
 
147
        0xcd, 0xb6, 0xb7, 0xc0, 0xb4, 0xb5, 0xb1, 0xb1, 0xaa, 0xca, 0xd1, 0xb4,
 
148
        0xe3, 0xd7, 0xb5, 0xe2, 0xc1, 0xb0, 0xdb, 0xa8, 0xa3, 0xd2, 0x8a, 0xa9,
 
149
        0xb7, 0x7e, 0xa2, 0xbd, 0x89, 0xa9, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
 
150
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
151
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
152
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xc9, 0xaf, 0xaf,
 
153
        0xc5, 0xb5, 0xb8, 0xb8, 0xb1, 0xb1, 0xb6, 0xbb, 0xad, 0xd0, 0xd6, 0xb5,
 
154
        0xe3, 0xd7, 0xb5, 0xe2, 0xbf, 0xaf, 0xdd, 0xb4, 0xa9, 0xdb, 0x92, 0x9a,
 
155
        0xc6, 0x84, 0xa7, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
156
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
157
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
158
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
 
159
        0x00, 0x00, 0x00, 0xac, 0xaa, 0xa6, 0xbd, 0xc3, 0xb0, 0xd2, 0xd7, 0xb5,
 
160
        0xe3, 0xd7, 0xb5, 0xe2, 0xbf, 0xae, 0xdb, 0xb6, 0xa8, 0x00, 0x00, 0x00,
 
161
        0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
162
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
163
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
164
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
165
        0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 
166
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
 
167
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
168
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
169
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
170
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
171
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
172
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
173
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
174
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
175
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
176
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
177
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
178
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
179
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
180
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
181
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
182
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
183
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
184
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
185
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
 
186
        0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff
 
187
};
 
188
 
 
189
 
 
190
static const char * book_open_xpm[] = {
 
191
"16 16 4 1",
 
192
"       c None s None",
 
193
".      c black",
 
194
"X      c #808080",
 
195
"o      c white",
 
196
"                ",
 
197
"  ..            ",
 
198
" .Xo.    ...    ",
 
199
" .Xoo. ..oo.    ",
 
200
" .Xooo.Xooo...  ",
 
201
" .Xooo.oooo.X.  ",
 
202
" .Xooo.Xooo.X.  ",
 
203
" .Xooo.oooo.X.  ",
 
204
" .Xooo.Xooo.X.  ",
 
205
" .Xooo.oooo.X.  ",
 
206
"  .Xoo.Xoo..X.  ",
 
207
"   .Xo.o..ooX.  ",
 
208
"    .X..XXXXX.  ",
 
209
"    ..X.......  ",
 
210
"     ..         ",
 
211
"                "};
 
212
 
 
213
static const char * book_closed_xpm[] = {
 
214
"16 16 6 1",
 
215
"       c None s None",
 
216
".      c black",
 
217
"X      c red",
 
218
"o      c yellow",
 
219
"O      c #808080",
 
220
"#      c white",
 
221
"                ",
 
222
"       ..       ",
 
223
"     ..XX.      ",
 
224
"   ..XXXXX.     ",
 
225
" ..XXXXXXXX.    ",
 
226
".ooXXXXXXXXX.   ",
 
227
"..ooXXXXXXXXX.  ",
 
228
".X.ooXXXXXXXXX. ",
 
229
".XX.ooXXXXXX..  ",
 
230
" .XX.ooXXX..#O  ",
 
231
"  .XX.oo..##OO. ",
 
232
"   .XX..##OO..  ",
 
233
"    .X.#OO..    ",
 
234
"     ..O..      ",
 
235
"      ..        ",
 
236
"                "};
 
237
 
 
238
static const char * mini_page_xpm[] = {
 
239
"16 16 4 1",
 
240
"       c None s None",
 
241
".      c black",
 
242
"X      c white",
 
243
"o      c #808080",
 
244
"                ",
 
245
"   .......      ",
 
246
"   .XXXXX..     ",
 
247
"   .XoooX.X.    ",
 
248
"   .XXXXX....   ",
 
249
"   .XooooXoo.o  ",
 
250
"   .XXXXXXXX.o  ",
 
251
"   .XooooooX.o  ",
 
252
"   .XXXXXXXX.o  ",
 
253
"   .XooooooX.o  ",
 
254
"   .XXXXXXXX.o  ",
 
255
"   .XooooooX.o  ",
 
256
"   .XXXXXXXX.o  ",
 
257
"   ..........o  ",
 
258
"    oooooooooo  ",
 
259
"                "};
 
260
 
 
261
static const char * gtk_mini_xpm[] = {
 
262
"15 20 17 1",
 
263
"       c None",
 
264
".      c #14121F",
 
265
"+      c #278828",
 
266
"@      c #9B3334",
 
267
"#      c #284C72",
 
268
"$      c #24692A",
 
269
"%      c #69282E",
 
270
"&      c #37C539",
 
271
"*      c #1D2F4D",
 
272
"=      c #6D7076",
 
273
"-      c #7D8482",
 
274
";      c #E24A49",
 
275
">      c #515357",
 
276
",      c #9B9C9B",
 
277
"'      c #2FA232",
 
278
")      c #3CE23D",
 
279
"!      c #3B6CCB",
 
280
"               ",
 
281
"      ***>     ",
 
282
"    >.*!!!*    ",
 
283
"   ***....#*=  ",
 
284
"  *!*.!!!**!!# ",
 
285
" .!!#*!#*!!!!# ",
 
286
" @%#!.##.*!!$& ",
 
287
" @;%*!*.#!#')) ",
 
288
" @;;@%!!*$&)'' ",
 
289
" @%.%@%$'&)$+' ",
 
290
" @;...@$'*'*)+ ",
 
291
" @;%..@$+*.')$ ",
 
292
" @;%%;;$+..$)# ",
 
293
" @;%%;@$$$'.$# ",
 
294
" %;@@;;$$+))&* ",
 
295
"  %;;;@+$&)&*  ",
 
296
"   %;;@'))+>   ",
 
297
"    %;@'&#     ",
 
298
"     >%$$      ",
 
299
"      >=       "};
 
300
 
 
301
const gchar ** xpms[] = { 
 
302
  book_open_xpm,
 
303
  book_closed_xpm,
 
304
  mini_page_xpm,
 
305
  gtk_mini_xpm,
 
306
  NULL
 
307
};
 
308
 
 
309
static void
 
310
quit_func (GtkWidget *widget, gpointer dummy)
 
311
{
 
312
        gtk_main_quit ();
 
313
}
 
314
 
 
315
static void
 
316
expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
 
317
{
 
318
        GdkPixbuf *pixbuf;
 
319
 
 
320
        pixbuf = (GdkPixbuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
 
321
 
 
322
        if (gdk_pixbuf_get_has_alpha (pixbuf)) {
 
323
                gdk_draw_rgb_32_image (drawing_area->window,
 
324
                                       drawing_area->style->black_gc,
 
325
                                       event->area.x, event->area.y, 
 
326
                                       event->area.width, 
 
327
                                       event->area.height,
 
328
                                       GDK_RGB_DITHER_MAX, 
 
329
                                       gdk_pixbuf_get_pixels (pixbuf)
 
330
                                       + (event->area.y * gdk_pixbuf_get_rowstride (pixbuf)) 
 
331
                                       + (event->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
 
332
                                       gdk_pixbuf_get_rowstride (pixbuf));
 
333
        } else {
 
334
                gdk_draw_rgb_image (drawing_area->window,
 
335
                                    drawing_area->style->white_gc,
 
336
                                    event->area.x, event->area.y, 
 
337
                                    event->area.width, 
 
338
                                    event->area.height,
 
339
                                    GDK_RGB_DITHER_NORMAL,
 
340
                                    gdk_pixbuf_get_pixels (pixbuf)
 
341
                                    + (event->area.y * gdk_pixbuf_get_rowstride (pixbuf))
 
342
                                    + (event->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
 
343
                                    gdk_pixbuf_get_rowstride (pixbuf));
 
344
        }
 
345
}
 
346
 
 
347
static void
 
348
config_func (GtkWidget *drawing_area, GdkEventConfigure *event, gpointer data)
 
349
{
 
350
        GdkPixbuf *pixbuf;
 
351
    
 
352
        pixbuf = (GdkPixbuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
 
353
 
 
354
        g_print("X:%d Y:%d\n", event->width, event->height);
 
355
 
 
356
#if 0
 
357
        if (((event->width) != gdk_pixbuf_get_width (pixbuf)) ||
 
358
            ((event->height) != gdk_pixbuf_get_height (pixbuf)))
 
359
                gdk_pixbuf_scale(pixbuf, event->width, event->height);
 
360
#endif
 
361
}
 
362
 
 
363
static GtkWidget*
 
364
new_testrgb_window (GdkPixbuf *pixbuf, gchar *title)
 
365
{
 
366
        GtkWidget *window;
 
367
        GtkWidget *vbox;
 
368
        GtkWidget *temp_box;
 
369
        GtkWidget *button;
 
370
        GtkWidget *drawing_area;
 
371
        gint w, h;
 
372
 
 
373
        g_return_val_if_fail (pixbuf != NULL, NULL);
 
374
        w = gdk_pixbuf_get_width (pixbuf);
 
375
        h = gdk_pixbuf_get_height (pixbuf);
 
376
 
 
377
        window = gtk_widget_new (gtk_window_get_type (),
 
378
                                 "GtkObject::user_data", NULL,
 
379
                                 "GtkWindow::type", GTK_WINDOW_TOPLEVEL,
 
380
                                 "GtkWindow::title", "testrgb",
 
381
                                 "GtkWindow::allow_shrink", TRUE,
 
382
                                 NULL);
 
383
        gtk_signal_connect (GTK_OBJECT (window), "destroy",
 
384
                            (GtkSignalFunc) quit_func, NULL);
 
385
 
 
386
        vbox = gtk_vbox_new (FALSE, 0);
 
387
 
 
388
        if (title)
 
389
                gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (title),
 
390
                                    TRUE, TRUE, 0);
 
391
 
 
392
        drawing_area = gtk_drawing_area_new ();
 
393
        gtk_object_set_data (GTK_OBJECT (window), "drawing_area", drawing_area);
 
394
 
 
395
        temp_box = gtk_hbox_new (FALSE, 0);
 
396
        gtk_drawing_area_size (GTK_DRAWING_AREA(drawing_area), w, h);
 
397
        gtk_box_pack_start (GTK_BOX (temp_box), drawing_area, FALSE, FALSE, 0);
 
398
        gtk_box_pack_start (GTK_BOX (vbox), temp_box, FALSE, FALSE, 0);
 
399
        
 
400
 
 
401
        gtk_signal_connect (GTK_OBJECT(drawing_area), "expose_event",
 
402
                            GTK_SIGNAL_FUNC(expose_func), NULL);
 
403
        gtk_signal_connect (GTK_OBJECT(drawing_area), "configure_event",
 
404
                            GTK_SIGNAL_FUNC (config_func), NULL);
 
405
 
 
406
        gtk_object_set_data (GTK_OBJECT(drawing_area), "pixbuf", pixbuf);
 
407
 
 
408
        gtk_widget_show (drawing_area);
 
409
 
 
410
        button = gtk_button_new_with_label ("Quit");
 
411
        gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
 
412
        gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
 
413
                                   (GtkSignalFunc) gtk_widget_destroy,
 
414
                                   GTK_OBJECT (window));
 
415
 
 
416
        gtk_widget_show (button);
 
417
 
 
418
        gtk_container_add (GTK_CONTAINER (window), vbox);
 
419
        gtk_widget_show_all (vbox);
 
420
 
 
421
        gtk_widget_show (window);
 
422
 
 
423
        return window;
 
424
}
 
425
 
 
426
 
 
427
static gint
 
428
update_timeout(gpointer data)
 
429
{
 
430
        ProgressFileStatus *status = data;
 
431
        gboolean done, error;
 
432
 
 
433
        done = FALSE;
 
434
        error = FALSE;
 
435
        if (!feof(status->imagefile)) {
 
436
                gint nbytes;
 
437
 
 
438
                nbytes = fread(status->buf, 1, status->readlen, 
 
439
                               status->imagefile);
 
440
 
 
441
                error = !gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (status->loader), status->buf, nbytes);
 
442
                if (error) {
 
443
                        G_BREAKPOINT();
 
444
                }
 
445
        } else { /* Really done */ 
 
446
                GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf (status->loader); 
 
447
                new_testrgb_window (pixbuf, "After progressive load"); 
 
448
                done = TRUE; 
 
449
        }
 
450
 
 
451
        if (error) { 
 
452
                g_warning ("Serious error writing to loader"); 
 
453
                done = TRUE; 
 
454
        } 
 
455
 
 
456
        if (done) {
 
457
                gtk_widget_queue_draw(*status->rgbwin);
 
458
                gdk_pixbuf_loader_close (GDK_PIXBUF_LOADER (status->loader));
 
459
                gtk_object_destroy (GTK_OBJECT(status->loader));
 
460
                fclose (status->imagefile);
 
461
                g_free (status->buf);
 
462
        }
 
463
 
 
464
        return !done;
 
465
}
 
466
 
 
467
 
 
468
static void
 
469
progressive_prepared_callback(GdkPixbufLoader* loader, gpointer data)
 
470
{
 
471
        GtkWidget** retloc = data;
 
472
        GdkPixbuf* pixbuf;
 
473
 
 
474
        pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
 
475
        g_assert(pixbuf != NULL);
 
476
 
 
477
        gdk_pixbuf_ref(pixbuf); /* for the RGB window */
 
478
 
 
479
        *retloc = new_testrgb_window(pixbuf, "Progressive");
 
480
 
 
481
        return;
 
482
}
 
483
 
 
484
 
 
485
static void
 
486
progressive_updated_callback(GdkPixbufLoader* loader, guint x, guint y, guint width, guint height, gpointer data)
 
487
{
 
488
        GtkWidget** window_loc = data;
 
489
        GtkDrawingArea *drawing_area;
 
490
        GdkRectangle r;
 
491
 
 
492
        g_assert (*window_loc != NULL);
 
493
 
 
494
        drawing_area = gtk_object_get_data (*window_loc, "drawing_area");
 
495
        g_assert (drawing_area != NULL);
 
496
 
 
497
        r.x = x;
 
498
        r.y = y;
 
499
        r.width = width;
 
500
        r.height = height;
 
501
        gtk_widget_draw (GTK_WIDGET (drawing_area), &r);
 
502
}
 
503
 
 
504
static int readlen = 4096;
 
505
 
 
506
int
 
507
main (int argc, char **argv)
 
508
{
 
509
        int i;
 
510
        int found_valid = FALSE;
 
511
 
 
512
        GdkPixbuf *pixbuf;
 
513
        GdkPixbufLoader *pixbuf_loader;
 
514
 
 
515
        gtk_init (&argc, &argv);
 
516
 
 
517
        gdk_rgb_set_verbose (TRUE);
 
518
 
 
519
        gdk_rgb_init ();
 
520
 
 
521
        gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
 
522
        gtk_widget_set_default_visual (gdk_rgb_get_visual ());
 
523
 
 
524
        {
 
525
                char *tbf_readlen = getenv("TBF_READLEN");
 
526
                if(tbf_readlen) readlen = atoi(tbf_readlen);
 
527
        }
 
528
 
 
529
        {
 
530
                char *tbf_bps = getenv("TBF_KBPS");
 
531
                guint bps;
 
532
 
 
533
                if (tbf_bps) {
 
534
                        bps = atoi(tbf_bps);
 
535
                        g_print ("Simulating %d kBytes/sec\n", bps);
 
536
                        readlen = (bps*1024)/10;
 
537
                }
 
538
        }
 
539
 
 
540
        i = 1;
 
541
        if (argc == 1) {
 
542
                const gchar*** xpmp;
 
543
                
 
544
                pixbuf = gdk_pixbuf_new_from_data (default_image, GDK_COLORSPACE_RGB, FALSE, 8,
 
545
                                                   DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_WIDTH * 3,
 
546
                                                   NULL, NULL);
 
547
                new_testrgb_window (pixbuf, NULL);
 
548
 
 
549
                xpmp = xpms;
 
550
                while (*xpmp) {
 
551
                        pixbuf = gdk_pixbuf_new_from_xpm_data (*xpmp);
 
552
                        new_testrgb_window (pixbuf, NULL);
 
553
                        ++xpmp;
 
554
                }
 
555
                
 
556
                found_valid = TRUE;
 
557
        } else {
 
558
                for (i = 1; i < argc; i++) {
 
559
 
 
560
                        pixbuf = gdk_pixbuf_new_from_file (argv[i]);
 
561
#if 0
 
562
                        pixbuf = gdk_pixbuf_rotate(pixbuf, 10.0);
 
563
#endif
 
564
 
 
565
                        if (pixbuf) {
 
566
                                new_testrgb_window (pixbuf, "File");
 
567
                                found_valid = TRUE;
 
568
                        }
 
569
                }
 
570
#if 1
 
571
                readlen=4096;
 
572
                {
 
573
                        GtkWidget* rgb_window = NULL;
 
574
                        static ProgressFileStatus   status;
 
575
 
 
576
                        pixbuf_loader = gdk_pixbuf_loader_new ();
 
577
                        status.loader = pixbuf_loader;
 
578
 
 
579
                        status.rgbwin = &rgb_window;
 
580
 
 
581
                        status.buf = g_malloc (readlen);
 
582
                        gtk_signal_connect(GTK_OBJECT(pixbuf_loader),
 
583
                                           "area_prepared",
 
584
                                           GTK_SIGNAL_FUNC(progressive_prepared_callback),
 
585
                                           &rgb_window);
 
586
 
 
587
                        gtk_signal_connect(GTK_OBJECT(pixbuf_loader),
 
588
                                           "area_updated",
 
589
                                           GTK_SIGNAL_FUNC(progressive_updated_callback),
 
590
                                           &rgb_window);
 
591
 
 
592
                        
 
593
                        status.imagefile = fopen (argv[1], "r");
 
594
                        g_assert (status.imagefile != NULL);
 
595
 
 
596
                        status.readlen = readlen;
 
597
 
 
598
                        status.timeout = gtk_timeout_add(100, update_timeout, &status);
 
599
                }
 
600
#endif
 
601
        }
 
602
 
 
603
        if (found_valid)
 
604
                gtk_main ();
 
605
 
 
606
        return 0;
 
607
}