1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
3  *
4  * Copyright (C) 2008 Dominic Lachowicz
5  * Copyright (C) 2008 Alberto Ruiz
6  *
7  * Authors: Dominic Lachowicz <domlachowicz@gmail.com>
8  *          Alberto Ruiz <aruiz@gnome.org>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include "config.h"
23 #include <glib/gi18n-lib.h>
24 
25 #include "io-gdip-utils.h"
26 
27 static gboolean
gdk_pixbuf__gdip_image_save_BMP_to_callback(GdkPixbufSaveFunc save_func,gpointer user_data,GdkPixbuf * pixbuf,gchar ** keys,gchar ** values,GError ** error)28 gdk_pixbuf__gdip_image_save_BMP_to_callback (GdkPixbufSaveFunc   save_func,
29                                              gpointer            user_data,
30                                              GdkPixbuf          *pixbuf,
31                                              gchar             **keys,
32                                              gchar             **values,
33                                              GError            **error)
34 {
35   return gdip_save_pixbuf (pixbuf, L"image/bmp", NULL, save_func, user_data, error);
36 }
37 
38 static gboolean
gdk_pixbuf__gdip_image_save_BMP(FILE * f,GdkPixbuf * pixbuf,gchar ** keys,gchar ** values,GError ** error)39 gdk_pixbuf__gdip_image_save_BMP (FILE          *f,
40                                  GdkPixbuf     *pixbuf,
41                                  gchar        **keys,
42                                  gchar        **values,
43                                  GError       **error)
44 {
45   return gdk_pixbuf__gdip_image_save_BMP_to_callback (gdip_save_to_file_callback, f, pixbuf, keys, values, error);
46 }
47 
48 #ifndef INCLUDE_gdiplus
49 #define MODULE_ENTRY(function) G_MODULE_EXPORT void function
50 #else
51 #define MODULE_ENTRY(function) void _gdk_pixbuf__gdip_bmp_ ## function
52 #endif
53 
MODULE_ENTRY(fill_vtable)54 MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
55 {
56   gdip_fill_vtable (module);
57 
58   module->save_to_callback = gdk_pixbuf__gdip_image_save_BMP_to_callback;
59   module->save = gdk_pixbuf__gdip_image_save_BMP; /* for gtk < 2.14, you need to implement both. otherwise gdk-pixbuf-queryloaders fails */
60 }
61 
MODULE_ENTRY(fill_info)62 MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
63 {
64   static const GdkPixbufModulePattern signature[] = {
65     { "BM", NULL, 100 }, /* BMP */
66     { NULL, NULL, 0 }
67   };
68 
69   static const gchar *mime_types[] = {
70     "image/bmp",
71     "image/x-bmp",
72     "image/x-MS-bmp",
73     NULL
74   };
75 
76   static const gchar *extensions[] = {
77     "bmp",
78     NULL
79   };
80 
81   info->name        = "bmp";
82   info->signature   = (GdkPixbufModulePattern *) signature;
83   info->description = NC_("image format", "BMP");
84   info->mime_types  = (gchar **) mime_types;
85   info->extensions  = (gchar **) extensions;
86   info->flags       = GDK_PIXBUF_FORMAT_WRITABLE | GDK_PIXBUF_FORMAT_THREADSAFE;
87   info->license     = "LGPL";
88 }
89