~ubuntu-branches/ubuntu/precise/classpath/precise

« back to all changes in this revision

Viewing changes to native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2006-05-27 16:11:15 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060527161115-h6e39eposdt5snb6
Tags: 2:0.91-3
* Install header files to /usr/include/classpath.
* debian/control: classpath: Conflict with jamvm < 1.4.3 and
  cacao < 0.96 (Closes: #368172).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* gtkimage.c
2
 
   Copyright (C) 2005 Free Software Foundation, Inc.
 
2
   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
3
3
 
4
4
This file is part of GNU Classpath.
5
5
 
65
65
  int width, height;
66
66
  GdkPixbuf *pixbuf;
67
67
 
68
 
  gdk_threads_enter ();
69
 
 
70
68
  /* Don't use the JCL convert function because it throws an exception
71
69
     on failure */
72
70
  filename = (*env)->GetStringUTFChars (env, name, 0);
73
71
 
74
72
  if (filename == NULL)
75
 
    {
76
 
      gdk_threads_leave ();
77
 
      return JNI_FALSE;
78
 
    }
 
73
    return JNI_FALSE;
79
74
 
80
75
  pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
81
76
  if (pixbuf == NULL)
82
77
    {
83
78
      (*env)->ReleaseStringUTFChars (env, name, filename);
84
 
      gdk_threads_leave ();
85
79
      return JNI_FALSE;
86
80
    }
87
81
 
92
86
  setWidthHeight(env, obj, width, height);
93
87
  (*env)->ReleaseStringUTFChars (env, name, filename);
94
88
 
95
 
  gdk_threads_leave ();
96
 
 
97
89
  return JNI_TRUE;
98
90
}
99
91
 
111
103
  int width;
112
104
  int height;
113
105
 
114
 
  gdk_threads_enter ();
115
 
 
116
106
  src = (*env)->GetByteArrayElements (env, data, NULL);
117
107
  len = (*env)->GetArrayLength (env, data);
118
108
 
128
118
  if (pixbuf == NULL)
129
119
    {
130
120
      createRawData (env, obj, NULL);
131
 
 
132
 
      gdk_threads_leave ();
133
 
 
134
121
      return JNI_FALSE;
135
122
    }
136
123
 
140
127
  createRawData (env, obj, pixbuf);
141
128
  setWidthHeight(env, obj, width, height);
142
129
 
143
 
  gdk_threads_leave ();
144
 
 
145
130
  return JNI_TRUE;
146
131
}
147
132
 
151
136
{
152
137
  int width, heigth;
153
138
  GdkPixbuf *pixbuf = (GdkPixbuf *) getData (env, obj);
154
 
  gdk_threads_enter ();
155
139
  width =  gdk_pixbuf_get_width (pixbuf);
156
140
  heigth = gdk_pixbuf_get_height (pixbuf);
157
 
  gdk_threads_leave ();
158
141
  setWidthHeight(env, obj, width, heigth);
159
142
}
160
143
 
171
154
  jint *result_array_iter, *dst;
172
155
  int i,j;
173
156
 
174
 
  gdk_threads_enter ();
175
 
 
176
157
  pixbuf = cp_gtk_image_get_pixbuf (env, obj);
177
158
  width =  gdk_pixbuf_get_width (pixbuf);
178
159
  height = gdk_pixbuf_get_height (pixbuf);
214
195
 
215
196
  (*env)->ReleaseIntArrayElements (env, result_array, result_array_iter, 0);
216
197
    
217
 
  gdk_threads_leave ();
218
 
 
219
198
  return result_array;
220
199
}
221
200
 
233
212
  jint *src_array_iter, *src;
234
213
  int i;
235
214
 
236
 
  gdk_threads_enter ();
237
 
 
238
215
  width =  gdk_pixbuf_get_width (pixbuf);
239
216
  height = gdk_pixbuf_get_height (pixbuf);
240
217
  rowstride = gdk_pixbuf_get_rowstride (pixbuf);
251
228
    }
252
229
 
253
230
  (*env)->ReleaseIntArrayElements (env, pixels, src_array_iter, 0);
254
 
 
255
 
  gdk_threads_leave ();
256
231
}
257
232
 
258
233
/**
265
240
  jclass cls;
266
241
  jfieldID field;
267
242
 
268
 
  gdk_threads_enter ();
269
 
 
270
243
  cls = (*env)->GetObjectClass (env, obj);
271
244
  field = (*env)->GetFieldID (env, cls, "width", "I");
272
245
  g_assert (field != 0);
285
258
  else
286
259
    createRawData (env, obj, gdk_pixmap_new (NULL, width, height,
287
260
                                             gdk_rgb_get_visual ()->depth));
288
 
 
289
 
  gdk_threads_leave ();
290
261
}
291
262
 
292
263
/**
295
266
JNIEXPORT void JNICALL
296
267
Java_gnu_java_awt_peer_gtk_GtkImage_freePixmap(JNIEnv *env, jobject obj)
297
268
{
298
 
  gdk_threads_enter ();
299
269
  if (offScreen (env, obj) == JNI_FALSE)
300
270
    gdk_pixbuf_unref ((GdkPixbuf *)getData (env, obj));
301
271
  else
302
272
    g_object_unref ((GdkPixmap *)getData (env, obj));
303
 
 
304
 
  gdk_threads_leave ();
305
273
}
306
274
 
307
275
/**
321
289
 
322
290
  GdkPixbuf *pixbuf;
323
291
 
324
 
  gdk_threads_enter ();
325
 
 
326
292
  cls = (*env)->GetObjectClass (env, destination);
327
293
  field = (*env)->GetFieldID (env, cls, "width", "I");
328
294
  g_assert (field != 0);
342
308
      gdk_pixbuf_unref (pixbuf);
343
309
 
344
310
  createRawData (env, destination, (void *)dst);
345
 
 
346
 
  gdk_threads_leave ();
347
311
}
348
312
 
349
313
/**