1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = gdk-pixbuf-Module-Interface.html 27 * outPack = gdkpixbuf 28 * outFile = PixbufFormat 29 * strct = GdkPixbufFormat 30 * realStrct= 31 * ctorStrct= 32 * clss = PixbufFormat 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gdk_pixbuf_format_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - gdk.Pixbuf 47 * - glib.ListSG 48 * - glib.Str 49 * structWrap: 50 * - GSList* -> ListSG 51 * - GdkPixbuf* -> Pixbuf 52 * - GdkPixbufFormat* -> PixbufFormat 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module gdkpixbuf.PixbufFormat; 59 60 public import gtkc.gdkpixbuftypes; 61 62 private import gtkc.gdkpixbuf; 63 private import glib.ConstructionException; 64 private import gobject.ObjectG; 65 66 67 private import gdk.Pixbuf; 68 private import glib.ListSG; 69 private import glib.Str; 70 71 72 73 74 /** 75 * Description 76 * If gdk-pixbuf; has been compiled with GModule support, it can be extended by 77 * modules which can load (and perhaps also save) new image and animation 78 * formats. Each loadable module must export a 79 * GdkPixbufModuleFillInfoFunc function named fill_info and 80 * a GdkPixbufModuleFillVtableFunc function named 81 * fill_vtable. 82 * In order to make format-checking work before actually loading the modules 83 * (which may require dlopening image libraries), modules export their 84 * signatures (and other information) via the fill_info 85 * function. An external utility, gdk-pixbuf-query-loaders, 86 * uses this to create a text file containing a list of all available loaders and 87 * their signatures. This file is then read at runtime by gdk-pixbuf; to obtain 88 * the list of available loaders and their signatures. 89 * Modules may only implement a subset of the functionality available via 90 * GdkPixbufModule. If a particular functionality is not implemented, the 91 * fill_vtable function will simply not set the corresponding 92 * function pointers of the GdkPixbufModule structure. If a module supports 93 * incremental loading (i.e. provides begin_load, stop_load and 94 * load_increment), it doesn't have to implement load, since gdk-pixbuf; can 95 * supply a generic load implementation wrapping the incremental loading. 96 * Installing a module is a two-step process: 97 * copy the module file(s) to the loader directory (normally 98 * libdir/gtk-2.0/version/loaders, 99 * unless overridden by the environment variable 100 * GDK_PIXBUF_MODULEDIR) 101 * call gdk-pixbuf-query-loaders to update the 102 * module file (normally 103 * sysconfdir/gtk-2.0/gdk-pixbuf.loaders, 104 * unless overridden by the environment variable 105 * GDK_PIXBUF_MODULE_FILE) 106 * The gdk-pixbuf; interfaces needed for implementing modules are contained in 107 * gdk-pixbuf-io.h (and 108 * gdk-pixbuf-animation.h if the module supports animations). 109 * They are not covered by the same stability guarantees as the regular 110 * gdk-pixbuf; API. To underline this fact, they are protected by 111 * #ifdef GDK_PIXBUF_ENABLE_BACKEND. 112 */ 113 public class PixbufFormat 114 { 115 116 /** the main Gtk struct */ 117 protected GdkPixbufFormat* gdkPixbufFormat; 118 119 120 public GdkPixbufFormat* getPixbufFormatStruct() 121 { 122 return gdkPixbufFormat; 123 } 124 125 126 /** the main Gtk struct as a void* */ 127 protected void* getStruct() 128 { 129 return cast(void*)gdkPixbufFormat; 130 } 131 132 /** 133 * Sets our main struct and passes it to the parent class 134 */ 135 public this (GdkPixbufFormat* gdkPixbufFormat) 136 { 137 this.gdkPixbufFormat = gdkPixbufFormat; 138 } 139 140 /** 141 * Description 142 * The gdk-pixbuf; library provides a simple mechanism for loading 143 * an image from a file in synchronous fashion. This means that the 144 * library takes control of the application while the file is being 145 * loaded; from the user's point of view, the application will block 146 * until the image is done loading. 147 * This interface can be used by applications in which blocking is 148 * acceptable while an image is being loaded. It can also be used to 149 * load small images in general. Applications that need progressive 150 * loading can use the GdkPixbufLoader functionality instead. 151 */ 152 153 /** 154 * Attaches a key/value pair as an option to a GdkPixbuf. If key already 155 * exists in the list of options attached to pixbuf, the new value is 156 * ignored and FALSE is returned. 157 * Since 2.2 158 * Params: 159 * pixbuf = a GdkPixbuf 160 * key = a nul-terminated string. 161 * value = a nul-terminated string. 162 * Returns: TRUE on success. 163 */ 164 public static int gdkPixbufSetOption(Pixbuf pixbuf, string key, string value) 165 { 166 // gboolean gdk_pixbuf_set_option (GdkPixbuf *pixbuf, const gchar *key, const gchar *value); 167 return gdk_pixbuf_set_option((pixbuf is null) ? null : pixbuf.getPixbufStruct(), Str.toStringz(key), Str.toStringz(value)); 168 } 169 170 /** 171 * Obtains the available information about the image formats supported 172 * by GdkPixbuf. 173 * Since 2.2 174 * Returns: A list of GdkPixbufFormats describing the supported image formats. The list should be freed when it is no longer needed, but the structures themselves are owned by GdkPixbuf and should not be freed. [transfer container][element-type GdkPixbufFormat] 175 */ 176 public static ListSG gdkPixbufGetFormats() 177 { 178 // GSList * gdk_pixbuf_get_formats (void); 179 auto p = gdk_pixbuf_get_formats(); 180 181 if(p is null) 182 { 183 return null; 184 } 185 186 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 187 } 188 189 /** 190 * Creates a copy of format 191 * Since 2.22 192 * Returns: the newly allocated copy of a GdkPixbufFormat. Use gdk_pixbuf_format_free() to free the resources when done 193 */ 194 public PixbufFormat copy() 195 { 196 // GdkPixbufFormat * gdk_pixbuf_format_copy (const GdkPixbufFormat *format); 197 auto p = gdk_pixbuf_format_copy(gdkPixbufFormat); 198 199 if(p is null) 200 { 201 return null; 202 } 203 204 return ObjectG.getDObject!(PixbufFormat)(cast(GdkPixbufFormat*) p); 205 } 206 207 /** 208 * Frees the resources allocated when copying a GdkPixbufFormat 209 * using gdk_pixbuf_format_copy() 210 * Since 2.22 211 */ 212 public void free() 213 { 214 // void gdk_pixbuf_format_free (GdkPixbufFormat *format); 215 gdk_pixbuf_format_free(gdkPixbufFormat); 216 } 217 218 /** 219 * Returns the name of the format. 220 * Since 2.2 221 * Returns: the name of the format. 222 */ 223 public string getName() 224 { 225 // gchar * gdk_pixbuf_format_get_name (GdkPixbufFormat *format); 226 return Str.toString(gdk_pixbuf_format_get_name(gdkPixbufFormat)); 227 } 228 229 /** 230 * Returns a description of the format. 231 * Since 2.2 232 * Returns: a description of the format. 233 */ 234 public string getDescription() 235 { 236 // gchar * gdk_pixbuf_format_get_description (GdkPixbufFormat *format); 237 return Str.toString(gdk_pixbuf_format_get_description(gdkPixbufFormat)); 238 } 239 240 /** 241 * Returns the mime types supported by the format. 242 * Since 2.2 243 * Returns: a NULL-terminated array of mime types which must be freed with g_strfreev() when it is no longer needed. [transfer full] 244 */ 245 public string[] getMimeTypes() 246 { 247 // gchar ** gdk_pixbuf_format_get_mime_types (GdkPixbufFormat *format); 248 return Str.toStringArray(gdk_pixbuf_format_get_mime_types(gdkPixbufFormat)); 249 } 250 251 /** 252 * Returns the filename extensions typically used for files in the 253 * given format. 254 * Since 2.2 255 * Returns: a NULL-terminated array of filename extensions which must be freed with g_strfreev() when it is no longer needed. [transfer full] 256 */ 257 public string[] getExtensions() 258 { 259 // gchar ** gdk_pixbuf_format_get_extensions (GdkPixbufFormat *format); 260 return Str.toStringArray(gdk_pixbuf_format_get_extensions(gdkPixbufFormat)); 261 } 262 263 /** 264 * Returns whether pixbufs can be saved in the given format. 265 * Since 2.2 266 * Returns: whether pixbufs can be saved in the given format. 267 */ 268 public int isWritable() 269 { 270 // gboolean gdk_pixbuf_format_is_writable (GdkPixbufFormat *format); 271 return gdk_pixbuf_format_is_writable(gdkPixbufFormat); 272 } 273 274 /** 275 * Returns whether this image format is scalable. If a file is in a 276 * scalable format, it is preferable to load it at the desired size, 277 * rather than loading it at the default size and scaling the 278 * resulting pixbuf to the desired size. 279 * Since 2.6 280 * Returns: whether this image format is scalable. 281 */ 282 public int isScalable() 283 { 284 // gboolean gdk_pixbuf_format_is_scalable (GdkPixbufFormat *format); 285 return gdk_pixbuf_format_is_scalable(gdkPixbufFormat); 286 } 287 288 /** 289 * Returns whether this image format is disabled. See 290 * gdk_pixbuf_format_set_disabled(). 291 * Since 2.6 292 * Returns: whether this image format is disabled. 293 */ 294 public int isDisabled() 295 { 296 // gboolean gdk_pixbuf_format_is_disabled (GdkPixbufFormat *format); 297 return gdk_pixbuf_format_is_disabled(gdkPixbufFormat); 298 } 299 300 /** 301 * Disables or enables an image format. If a format is disabled, 302 * gdk-pixbuf won't use the image loader for this format to load 303 * images. Applications can use this to avoid using image loaders 304 * with an inappropriate license, see gdk_pixbuf_format_get_license(). 305 * Since 2.6 306 * Params: 307 * disabled = TRUE to disable the format format 308 */ 309 public void setDisabled(int disabled) 310 { 311 // void gdk_pixbuf_format_set_disabled (GdkPixbufFormat *format, gboolean disabled); 312 gdk_pixbuf_format_set_disabled(gdkPixbufFormat, disabled); 313 } 314 315 /** 316 * Returns information about the license of the image loader for the format. The 317 * returned string should be a shorthand for a wellknown license, e.g. "LGPL", 318 * "GPL", "QPL", "GPL/QPL", or "other" to indicate some other license. This 319 * string should be freed with g_free() when it's no longer needed. 320 * Since 2.6 321 * Returns: a string describing the license of format. 322 */ 323 public string getLicense() 324 { 325 // gchar * gdk_pixbuf_format_get_license (GdkPixbufFormat *format); 326 return Str.toString(gdk_pixbuf_format_get_license(gdkPixbufFormat)); 327 } 328 329 /** 330 * Parses an image file far enough to determine its format and size. 331 * Since 2.4 332 * Params: 333 * filename = The name of the file to identify. 334 * width = Return location for the width of the image, or NULL 335 * height = Return location for the height of the image, or NULL 336 * Returns: A GdkPixbufFormat describing the image format of the file or NULL if the image format wasn't recognized. The return value is owned by GdkPixbuf and should not be freed. 337 */ 338 public static PixbufFormat getFileInfo(string filename, out int width, out int height) 339 { 340 // GdkPixbufFormat * gdk_pixbuf_get_file_info (const gchar *filename, gint *width, gint *height); 341 auto p = gdk_pixbuf_get_file_info(Str.toStringz(filename), &width, &height); 342 343 if(p is null) 344 { 345 return null; 346 } 347 348 return ObjectG.getDObject!(PixbufFormat)(cast(GdkPixbufFormat*) p); 349 } 350 }