; Module/File: Pixbuf_Composite.pb ; Function: Composite pixbuf with full or checkered colored background + alpha - Linux ; Author: Omi ; Date: Jun. 18, 2016 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.31/5.4 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- ;System icon are loaded by name as pixbufs (same as ImageID(#Image) and can be used everywhere, ImageID(#Image) is used. ;If Icon doesn't exist, '0' is returned and no Image is used -> NO CRASH !!! :-) EnableExplicit ;UsePNGImageDecoder(); :-) ImportC "" gtk_icon_theme_load_icon(*icon_theme.GtkIconTheme, icon_name.p-utf8, size, flags, *error.GError); gtk2.4+ gdk_pixbuf_composite_color_simple(*srcpixbuf, dest_width, dest_height, interp_type, overall_alpha, check_size, color1, color2) EndImport Enumeration GtkIconLookupFlags #GTK_ICON_LOOKUP_ALL = 0; Not gtk-defined, own constant to clearify #GTK_ICON_LOOKUP_NO_SVG = 1 #GTK_ICON_LOOKUP_FORCE_SVG = 2 #GTK_ICON_LOOKUP_USE_BUILTIN = 4 #GTK_ICON_LOOKUP_GENERIC_FALLBACK = 8 #GTK_ICON_LOOKUP_FORCE_SIZE = 16 EndEnumeration Enumeration GdkInterpType; see https://developer.gnome.org/gdk-pixbuf/unstable/gdk-pixbuf-Scaling.html#GdkInterpType #GDK_INTERP_NEAREST #GDK_INTERP_TILES #GDK_INTERP_BILINEAR #GDK_INTERP_HYPER EndEnumeration ; Object constants #Win_Main = 0 Global.i gEvent, gEventWin, gQuit Global *gPixbuf Procedure IconTheme_LoadIconFromName(icon_name.s, icon_size, flags) Protected *error.GError Protected *pixbuf= gtk_icon_theme_load_icon(gtk_icon_theme_get_default_(), icon_name, icon_size, flags, @*error) If *error : Debug icon_name + ": " + PeekS(*error\message, -1, #PB_UTF8) : EndIf ProcedureReturn *pixbuf EndProcedure Procedure Create_WinMain() If OpenWindow(#Win_Main, 300, 200, 550, 240, "pixbuf composite...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ; SetWindowColor (#Win_Main, $CFFFFF) *gPixbuf= IconTheme_LoadIconFromName("find", 64, #GTK_ICON_LOOKUP_ALL) TextGadget (#PB_Any, 5, 5, 250, 22, "Flip Pixbuf from System icon 'find' ...") TextGadget (#PB_Any, 5, 35, 240, 40, "ImageGadget:" + #LF$ + " Orig. pixbuf!") ImageGadget (0, 250, 30, 64, 64, *gPixbuf, #PB_Image_Border) TextGadget (#PB_Any, 5, 105, 240, 40, "ImageGadget composite with 'yellow/blueish' checkerboard:") ImageGadget (1, 250, 100, 64, 64, gdk_pixbuf_composite_color_simple(*gPixbuf, 64, 64, #GDK_INTERP_HYPER, $ff, 4, $ffff00, $e0e0ff)) TextGadget (#PB_Any, 5, 175, 240, 40, "ImageGadget composite with 'blueish' halftransp. background:") ImageGadget (2, 250, 170, 64, 64, gdk_pixbuf_composite_color_simple(*gPixbuf, 64, 64, #GDK_INTERP_BILINEAR, $7f, 64, $dfdfff, $0)) EndIf EndProcedure Create_WinMain() Repeat gEvent= WaitWindowEvent() Select gEvent Case #PB_Event_CloseWindow gQuit= #True EndSelect Until gQuit ; IDE Options = PureBasic 5.44 LTS (Linux - x86) ; CursorPosition = 29 ; Folding = - ; EnableUnicode ; EnableXP