X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=libs%2Fgtkutil%2Fimage.cpp;fp=libs%2Fgtkutil%2Fimage.cpp;h=a79b5b144b1d77bc86e296c1045ce886d531eabd;hb=c3765eb6e7f6879e5a34c48f71e5ee7bc8b8851f;hp=2791fd47393a09a921458c8b31839e6392af8273;hpb=6f51c7f28dc9f56ae64e7da7d42dcbaa068da65a;p=xonotic%2Fnetradiant.git diff --git a/libs/gtkutil/image.cpp b/libs/gtkutil/image.cpp index 2791fd47..a79b5b14 100644 --- a/libs/gtkutil/image.cpp +++ b/libs/gtkutil/image.cpp @@ -21,8 +21,7 @@ #include "image.h" -#include -#include +#include #include "string/string.h" #include "stream/stringstream.h" @@ -46,41 +45,37 @@ GdkPixbuf* pixbuf_new_from_file_with_mask( const char* filename ){ else { //GdkPixbuf* rgba = gdk_pixbuf_add_alpha( rgb, TRUE, 255, 0, 255 ); //pink to alpha - GdkPixbuf* rgba = gdk_pixbuf_add_alpha( rgb, FALSE, 255, 0, 255 ); //alpha - gdk_pixbuf_unref( rgb ); + GdkPixbuf* rgba = gdk_pixbuf_add_alpha( rgb, FALSE, 255, 0, 255 ); + g_object_unref( rgb ); return rgba; } } -GtkImage* image_new_from_file_with_mask( const char* filename ){ +ui::Image image_new_from_file_with_mask( const char* filename ){ GdkPixbuf* rgba = pixbuf_new_from_file_with_mask( filename ); if ( rgba == 0 ) { - return 0; + return ui::Image(ui::null); } else { - GtkImage* image = GTK_IMAGE( gtk_image_new_from_pixbuf( rgba ) ); - gdk_pixbuf_unref( rgba ); + auto image = ui::Image::from( gtk_image_new_from_pixbuf( rgba ) ); + g_object_unref( rgba ); return image; } } -GtkImage* image_new_missing(){ - return GTK_IMAGE( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ); +ui::Image image_new_missing(){ + return ui::Image::from( gtk_image_new_from_stock( GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR ) ); } -GtkImage* new_image( const char* filename ){ - { - GtkImage* image = image_new_from_file_with_mask( filename ); - if ( image != 0 ) { - return image; - } +ui::Image new_image( const char* filename ){ + if ( auto image = image_new_from_file_with_mask( filename ) ) { + return image; } - return image_new_missing(); } -GtkImage* new_local_image( const char* filename ){ +ui::Image new_local_image( const char* filename ){ StringOutputStream fullPath( 256 ); fullPath << g_bitmapsPath.c_str() << filename; return new_image( fullPath.c_str() );