~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/bmp/bmp.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* bmp.c                                          */
2
 
/* Version 0.51                                   */
 
2
/* Version 0.52                                   */
3
3
/* This is a File input and output filter for the */
4
4
/* Gimp. It loads and saves images in windows(TM) */
5
5
/* bitmap format.                                 */
12
12
 
13
13
/* Changes:   28.11.1997 Noninteractive operation */
14
14
/*            16.03.1998 Endian-independent!!     */
15
 
/*            21.03.1998 Little Bug-fix           */
 
15
/*            21.03.1998 Little Bug-fix           */
16
16
/*            06.04.1998 Bugfix in Padding        */
17
17
/*            11.04.1998 Arch. cleanup (-Wall)    */
18
18
/*                       Parses gtkrc             */
27
27
/*            06.05.2000 Overhaul for 16&24-bit   */
28
28
/*                       plus better OS/2 code    */
29
29
/*                       by njl195@zepler.org.uk  */
 
30
/*            29.06.2006 Full support for 16/32   */
 
31
/*                       bits bitmaps and support */
 
32
/*                       for alpha channel        */
 
33
/*                       by p.filiciak@zax.pl     */
30
34
 
31
35
/*
32
 
 * The GIMP -- an image manipulation program
 
36
 * GIMP - The GNU Image Manipulation Program
33
37
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
34
38
 *
35
39
 * This program is free software; you can redistribute it and/or modify
50
54
 
51
55
#include "config.h"
52
56
 
53
 
#include <stdio.h>
54
57
#include <stdlib.h>
55
58
#include <string.h>
56
59
 
57
 
#include <gtk/gtk.h>
58
 
 
59
60
#include <libgimp/gimp.h>
60
61
#include <libgimp/gimpui.h>
61
62
 
63
64
 
64
65
#include "libgimp/stdplugins-intl.h"
65
66
 
66
 
const gchar *filename  = NULL;
67
 
gboolean     interactive_bmp;
 
67
 
 
68
const gchar *filename    = NULL;
 
69
gboolean     interactive = FALSE;
 
70
gboolean     lastvals    = FALSE;
68
71
 
69
72
struct Bitmap_File_Head_Struct Bitmap_File_Head;
70
 
struct Bitmap_Head_Struct Bitmap_Head;
 
73
struct Bitmap_Head_Struct      Bitmap_Head;
 
74
 
71
75
 
72
76
/* Declare some local functions.
73
77
 */
78
82
                     gint             *nreturn_vals,
79
83
                     GimpParam       **return_vals);
80
84
 
81
 
GimpPlugInInfo PLUG_IN_INFO =
 
85
const GimpPlugInInfo PLUG_IN_INFO =
82
86
{
83
87
  NULL,  /* init_proc  */
84
88
  NULL,  /* quit_proc  */
91
95
static void
92
96
query (void)
93
97
{
94
 
  static GimpParamDef load_args[] =
 
98
  static const GimpParamDef load_args[] =
95
99
  {
96
 
    { GIMP_PDB_INT32,    "run_mode",     "Interactive, non-interactive" },
 
100
    { GIMP_PDB_INT32,    "run-mode",     "Interactive, non-interactive" },
97
101
    { GIMP_PDB_STRING,   "filename",     "The name of the file to load" },
98
 
    { GIMP_PDB_STRING,   "raw_filename", "The name entered" },
 
102
    { GIMP_PDB_STRING,   "raw-filename", "The name entered" },
99
103
  };
100
 
  static GimpParamDef load_return_vals[] =
 
104
  static const GimpParamDef load_return_vals[] =
101
105
  {
102
106
    { GIMP_PDB_IMAGE, "image", "Output image" },
103
107
  };
104
108
 
105
 
  static GimpParamDef save_args[] =
 
109
  static const GimpParamDef save_args[] =
106
110
  {
107
 
    { GIMP_PDB_INT32,    "run_mode",     "Interactive, non-interactive" },
 
111
    { GIMP_PDB_INT32,    "run-mode",     "Interactive, non-interactive" },
108
112
    { GIMP_PDB_IMAGE,    "image",        "Input image" },
109
113
    { GIMP_PDB_DRAWABLE, "drawable",     "Drawable to save" },
110
114
    { GIMP_PDB_STRING,   "filename",     "The name of the file to save the image in" },
111
 
    { GIMP_PDB_STRING,   "raw_filename", "The name entered" },
 
115
    { GIMP_PDB_STRING,   "raw-filename", "The name entered" },
112
116
  };
113
117
 
114
 
  gimp_install_procedure ("file_bmp_load",
 
118
  gimp_install_procedure (LOAD_PROC,
115
119
                          "Loads files of Windows BMP file format",
116
120
                          "Loads files of Windows BMP file format",
117
121
                          "Alexander Schulz",
124
128
                          G_N_ELEMENTS (load_return_vals),
125
129
                          load_args, load_return_vals);
126
130
 
127
 
  gimp_register_file_handler_mime ("file_bmp_load", "image/bmp");
128
 
  gimp_register_magic_load_handler ("file_bmp_load",
129
 
                                    "bmp",
130
 
                                    "",
131
 
                                    "0,string,BM");
 
131
  gimp_register_file_handler_mime (LOAD_PROC, "image/bmp");
 
132
  gimp_register_magic_load_handler (LOAD_PROC,
 
133
                                    "bmp",
 
134
                                    "",
 
135
                                    "0,string,BM");
132
136
 
133
 
  gimp_install_procedure ("file_bmp_save",
 
137
  gimp_install_procedure (SAVE_PROC,
134
138
                          "Saves files in Windows BMP file format",
135
139
                          "Saves files in Windows BMP file format",
136
140
                          "Alexander Schulz",
137
141
                          "Alexander Schulz",
138
142
                          "1997",
139
143
                          N_("Windows BMP image"),
140
 
                          "INDEXED, GRAY, RGB",
 
144
                          "INDEXED, GRAY, RGB*",
141
145
                          GIMP_PLUGIN,
142
146
                          G_N_ELEMENTS (save_args), 0,
143
147
                          save_args, NULL);
144
148
 
145
 
  gimp_register_file_handler_mime ("file_bmp_save", "image/bmp");
146
 
  gimp_register_save_handler ("file_bmp_save", "bmp", "");
 
149
  gimp_register_file_handler_mime (SAVE_PROC, "image/bmp");
 
150
  gimp_register_save_handler (SAVE_PROC, "bmp", "");
147
151
}
148
152
 
149
153
static void
169
173
  values[0].type          = GIMP_PDB_STATUS;
170
174
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
171
175
 
172
 
  if (strcmp (name, "file_bmp_load") == 0)
 
176
  if (strcmp (name, LOAD_PROC) == 0)
173
177
    {
174
178
       switch (run_mode)
175
179
        {
176
180
        case GIMP_RUN_INTERACTIVE:
177
 
          interactive_bmp = TRUE;
 
181
          interactive = TRUE;
178
182
          break;
179
183
 
180
184
        case GIMP_RUN_NONINTERACTIVE:
181
185
          /*  Make sure all the arguments are there!  */
182
 
          interactive_bmp = FALSE;
183
 
          if (nparams != 3)
 
186
          if (nparams != 3)
184
187
            status = GIMP_PDB_CALLING_ERROR;
185
188
          break;
186
189
 
189
192
        }
190
193
 
191
194
       if (status == GIMP_PDB_SUCCESS)
192
 
         {
193
 
           image_ID = ReadBMP (param[1].data.d_string);
 
195
         {
 
196
           image_ID = ReadBMP (param[1].data.d_string);
194
197
 
195
 
           if (image_ID != -1)
196
 
             {
197
 
               *nreturn_vals = 2;
198
 
               values[1].type         = GIMP_PDB_IMAGE;
199
 
               values[1].data.d_image = image_ID;
200
 
             }
201
 
           else
202
 
             {
203
 
               status = GIMP_PDB_EXECUTION_ERROR;
204
 
             }
205
 
         }
 
198
           if (image_ID != -1)
 
199
             {
 
200
               *nreturn_vals = 2;
 
201
               values[1].type         = GIMP_PDB_IMAGE;
 
202
               values[1].data.d_image = image_ID;
 
203
             }
 
204
           else
 
205
             {
 
206
               status = GIMP_PDB_EXECUTION_ERROR;
 
207
             }
 
208
         }
206
209
    }
207
 
  else if (strcmp (name, "file_bmp_save") == 0)
 
210
  else if (strcmp (name, SAVE_PROC) == 0)
208
211
    {
209
212
      image_ID    = param[1].data.d_int32;
210
213
      drawable_ID = param[2].data.d_int32;
211
214
 
212
215
      /*  eventually export the image */
213
216
      switch (run_mode)
214
 
        {
215
 
        case GIMP_RUN_INTERACTIVE:
216
 
        case GIMP_RUN_WITH_LAST_VALS:
217
 
          gimp_ui_init ("bmp", FALSE);
218
 
          export = gimp_export_image (&image_ID, &drawable_ID, "BMP",
219
 
                                      (GIMP_EXPORT_CAN_HANDLE_RGB |
220
 
                                       GIMP_EXPORT_CAN_HANDLE_GRAY |
221
 
                                       GIMP_EXPORT_CAN_HANDLE_INDEXED));
222
 
          if (export == GIMP_EXPORT_CANCEL)
223
 
            {
224
 
              values[0].data.d_status = GIMP_PDB_CANCEL;
225
 
              return;
226
 
            }
227
 
          break;
228
 
        default:
229
 
          break;
230
 
        }
231
 
 
232
 
      switch (run_mode)
233
217
        {
234
218
        case GIMP_RUN_INTERACTIVE:
235
 
          interactive_bmp = TRUE;
236
 
          break;
237
 
 
238
 
        case GIMP_RUN_NONINTERACTIVE:
239
 
          /*  Make sure all the arguments are there!  */
240
 
          interactive_bmp = FALSE;
241
 
          if (nparams != 5)
242
 
            status = GIMP_PDB_CALLING_ERROR;
243
 
          break;
 
219
          interactive = TRUE;
 
220
          /* fallthrough */
244
221
 
245
222
        case GIMP_RUN_WITH_LAST_VALS:
246
 
          interactive_bmp = FALSE;
 
223
          if (run_mode == GIMP_RUN_WITH_LAST_VALS) lastvals = TRUE;
 
224
          gimp_ui_init ("bmp", FALSE);
 
225
          export = gimp_export_image (&image_ID, &drawable_ID, "BMP",
 
226
                                      (GIMP_EXPORT_CAN_HANDLE_RGB |
 
227
                                       GIMP_EXPORT_CAN_HANDLE_ALPHA |
 
228
                                       GIMP_EXPORT_CAN_HANDLE_GRAY |
 
229
                                       GIMP_EXPORT_CAN_HANDLE_INDEXED));
 
230
 
 
231
          if (export == GIMP_EXPORT_CANCEL)
 
232
            {
 
233
              values[0].data.d_status = GIMP_PDB_CANCEL;
 
234
              return;
 
235
            }
 
236
          break;
 
237
 
 
238
        case GIMP_RUN_NONINTERACTIVE:
 
239
          /*  Make sure all the arguments are there!  */
 
240
          if (nparams != 5)
 
241
            status = GIMP_PDB_CALLING_ERROR;
247
242
          break;
248
243
 
249
244
        default:
251
246
        }
252
247
 
253
248
      if (status == GIMP_PDB_SUCCESS)
254
 
        {
255
 
          status = WriteBMP (param[3].data.d_string, image_ID, drawable_ID);
256
 
        }
 
249
        status = WriteBMP (param[3].data.d_string, image_ID, drawable_ID);
257
250
 
258
251
      if (export == GIMP_EXPORT_EXPORT)
259
 
        gimp_image_delete (image_ID);
 
252
        gimp_image_delete (image_ID);
260
253
    }
261
254
  else
262
255
    {