| 339 } |
339 } |
| 340 |
340 |
| 341 return 0; |
341 return 0; |
| 342 } |
342 } |
| 343 |
343 |
| |
344 UIEXPORT int ui_image_load_data(UiGeneric *obj, const void *imgdata, size_t size) { |
| |
345 GBytes *bytes = g_bytes_new_static(imgdata, size); |
| |
346 GInputStream *in = g_memory_input_stream_new_from_bytes(bytes); |
| |
347 GError *error = NULL; |
| |
348 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_stream(in, NULL, &error); |
| |
349 g_object_unref(in); |
| |
350 if(!pixbuf) { |
| |
351 return 1; |
| |
352 } |
| |
353 |
| |
354 if(obj->set) { |
| |
355 obj->set(obj, pixbuf, UI_IMAGE_OBJECT_TYPE); |
| |
356 g_object_unref(pixbuf); |
| |
357 } else { |
| |
358 obj->value = pixbuf; |
| |
359 } |
| |
360 |
| |
361 return 0; |
| |
362 } |
| |
363 |
| 344 void ui_image_ref(UIIMAGE img) { |
364 void ui_image_ref(UIIMAGE img) { |
| 345 g_object_ref(img); |
365 g_object_ref(img); |
| 346 } |
366 } |
| 347 |
367 |
| 348 void ui_image_unref(UIIMAGE img) { |
368 void ui_image_unref(UIIMAGE img) { |