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

« back to all changes in this revision

Viewing changes to plug-ins/fits/fits.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
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 * FITS file plugin
4
4
 * reading and writing code Copyright (C) 1997 Peter Kirchgessner
32
32
 *                        (moved it from load to save)
33
33
 */
34
34
 
35
 
static char ident[] = "@(#) GIMP FITS file-plugin v1.06  21-Nov-99";
36
 
 
37
35
#include "config.h"
38
36
 
 
37
#include <string.h>
39
38
#include <errno.h>
40
 
#include <stdio.h>
41
 
#include <stdlib.h>
42
 
#include <string.h>
43
39
 
44
 
#include <gtk/gtk.h>
 
40
#include <glib/gstdio.h>
45
41
 
46
42
#include <libgimp/gimp.h>
47
43
#include <libgimp/gimpui.h>
51
47
#include "libgimp/stdplugins-intl.h"
52
48
 
53
49
 
 
50
#define LOAD_PROC      "file-fits-load"
 
51
#define SAVE_PROC      "file-fits-save"
 
52
#define PLUG_IN_BINARY "fits"
 
53
 
 
54
 
54
55
/* Load info */
55
56
typedef struct
56
57
{
75
76
                          gint32        drawable_ID);
76
77
 
77
78
static FITS_HDU_LIST *create_fits_header (FITS_FILE *ofp,
78
 
                                          guint width, guint height, guint bpp);
 
79
                                          guint width,
 
80
                                          guint height,
 
81
                                          guint bpp);
79
82
static gint save_index  (FITS_FILE *ofp,
80
83
                         gint32 image_ID,
81
84
                         gint32 drawable_ID);
112
115
  0         /* Dont compose images */
113
116
};
114
117
 
115
 
GimpPlugInInfo PLUG_IN_INFO =
 
118
const GimpPlugInInfo PLUG_IN_INFO =
116
119
{
117
120
  NULL,  /* init_proc  */
118
121
  NULL,  /* quit_proc  */
130
133
query (void)
131
134
 
132
135
{
133
 
  static GimpParamDef load_args[] =
 
136
  static const GimpParamDef load_args[] =
134
137
  {
135
 
    { GIMP_PDB_INT32,    "run_mode",     "Interactive, non-interactive" },
 
138
    { GIMP_PDB_INT32,    "run-mode",     "Interactive, non-interactive" },
136
139
    { GIMP_PDB_STRING,   "filename",     "The name of the file to load" },
137
 
    { GIMP_PDB_STRING,   "raw_filename", "The name of the file to load" },
 
140
    { GIMP_PDB_STRING,   "raw-filename", "The name of the file to load" },
138
141
  };
139
 
  static GimpParamDef load_return_vals[] =
 
142
  static const GimpParamDef load_return_vals[] =
140
143
  {
141
144
    { GIMP_PDB_IMAGE,    "image",        "Output image" },
142
145
  };
143
146
 
144
 
  static GimpParamDef save_args[] =
 
147
  static const GimpParamDef save_args[] =
145
148
  {
146
 
    { GIMP_PDB_INT32,    "run_mode",     "Interactive, non-interactive" },
 
149
    { GIMP_PDB_INT32,    "run-mode",     "Interactive, non-interactive" },
147
150
    { GIMP_PDB_IMAGE,    "image",        "Input image" },
148
151
    { GIMP_PDB_DRAWABLE, "drawable",     "Drawable to save" },
149
152
    { GIMP_PDB_STRING,   "filename",     "The name of the file to save the image in" },
150
 
    { GIMP_PDB_STRING,   "raw_filename", "The name of the file to save the image in" },
 
153
    { GIMP_PDB_STRING,   "raw-filename", "The name of the file to save the image in" },
151
154
  };
152
155
 
153
 
  gimp_install_procedure ("file_fits_load",
 
156
  gimp_install_procedure (LOAD_PROC,
154
157
                          "load file of the FITS file format",
155
 
                          "load file of the FITS file format (Flexible Image Transport System)",
 
158
                          "load file of the FITS file format "
 
159
                          "(Flexible Image Transport System)",
156
160
                          "Peter Kirchgessner",
157
161
                          "Peter Kirchgessner (peter@kirchgessner.net)",
158
162
                          "1997",
163
167
                          G_N_ELEMENTS (load_return_vals),
164
168
                          load_args, load_return_vals);
165
169
 
166
 
  gimp_register_file_handler_mime ("file_fits_load", "image/x-fits");
167
 
  gimp_register_magic_load_handler ("file_fits_load",
 
170
  gimp_register_file_handler_mime (LOAD_PROC, "image/x-fits");
 
171
  gimp_register_magic_load_handler (LOAD_PROC,
168
172
                                    "fit,fits",
169
173
                                    "",
170
174
                                    "0,string,SIMPLE");
171
175
 
172
 
  gimp_install_procedure ("file_fits_save",
 
176
  gimp_install_procedure (SAVE_PROC,
173
177
                          "save file in the FITS file format",
174
 
                          "FITS saving handles all image types except those with alpha channels.",
 
178
                          "FITS saving handles all image types except "
 
179
                          "those with alpha channels.",
175
180
                          "Peter Kirchgessner",
176
181
                          "Peter Kirchgessner (peter@kirchgessner.net)",
177
182
                          "1997",
181
186
                          G_N_ELEMENTS (save_args), 0,
182
187
                          save_args, NULL);
183
188
 
184
 
  gimp_register_file_handler_mime ("file_fits_save", "image/x-fits");
185
 
  gimp_register_save_handler ("file_fits_save", "fit,fits", "");
 
189
  gimp_register_file_handler_mime (SAVE_PROC, "image/x-fits");
 
190
  gimp_register_save_handler (SAVE_PROC, "fit,fits", "");
186
191
}
187
192
 
188
193
 
209
214
  values[0].type          = GIMP_PDB_STATUS;
210
215
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
211
216
 
212
 
  if (strcmp (name, "file_fits_load") == 0)
 
217
  if (strcmp (name, LOAD_PROC) == 0)
213
218
    {
214
219
      switch (run_mode)
215
220
        {
216
221
        case GIMP_RUN_INTERACTIVE:
217
222
          /*  Possibly retrieve data  */
218
 
          gimp_get_data ("file_fits_load", &plvals);
 
223
          gimp_get_data (LOAD_PROC, &plvals);
219
224
 
220
225
          if (!load_dialog ())
221
226
            status = GIMP_PDB_CANCEL;
228
233
 
229
234
        case GIMP_RUN_WITH_LAST_VALS:
230
235
          /* Possibly retrieve data */
231
 
          gimp_get_data ("file_fits_load", &plvals);
 
236
          gimp_get_data (LOAD_PROC, &plvals);
232
237
          break;
233
238
 
234
239
        default:
256
261
 
257
262
          /*  Store plvals data  */
258
263
          if (status == GIMP_PDB_SUCCESS)
259
 
            gimp_set_data ("file_fits_load", &plvals, sizeof (FITSLoadVals));
 
264
            gimp_set_data (LOAD_PROC, &plvals, sizeof (FITSLoadVals));
260
265
        }
261
266
    }
262
 
  else if (strcmp (name, "file_fits_save") == 0)
 
267
  else if (strcmp (name, SAVE_PROC) == 0)
263
268
    {
264
269
      image_ID = param[1].data.d_int32;
265
270
      drawable_ID = param[2].data.d_int32;
269
274
        {
270
275
        case GIMP_RUN_INTERACTIVE:
271
276
        case GIMP_RUN_WITH_LAST_VALS:
272
 
          gimp_ui_init ("fits", FALSE);
 
277
          gimp_ui_init (PLUG_IN_BINARY, FALSE);
273
278
          export = gimp_export_image (&image_ID, &drawable_ID, "FITS",
274
279
                                      (GIMP_EXPORT_CAN_HANDLE_RGB |
275
280
                                       GIMP_EXPORT_CAN_HANDLE_GRAY |
331
336
  FITS_FILE *ifp;
332
337
  FITS_HDU_LIST *hdu;
333
338
 
334
 
  fp = fopen (filename, "rb");
 
339
  fp = g_fopen (filename, "rb");
335
340
  if (!fp)
336
341
    {
337
342
      g_message (_("Could not open '%s' for reading: %s"),
420
425
  FITS_FILE* ofp;
421
426
  GimpImageType drawable_type;
422
427
  gint retval;
423
 
  char *temp = ident; /* Just to satisfy lint/gcc */
424
428
 
425
429
  drawable_type = gimp_drawable_type (drawable_ID);
426
430
 
452
456
      return (FALSE);
453
457
    }
454
458
 
455
 
  temp = g_strdup_printf (_("Saving '%s'..."),
456
 
                          gimp_filename_to_utf8 (filename));
457
 
  gimp_progress_init (temp);
458
 
  g_free (temp);
 
459
  gimp_progress_init_printf (_("Saving '%s'"),
 
460
                             gimp_filename_to_utf8 (filename));
459
461
 
460
462
  if ((drawable_type == GIMP_INDEXED_IMAGE) ||
461
463
      (drawable_type == GIMP_INDEXEDA_IMAGE))
964
966
  GtkWidget *frame;
965
967
  gboolean   run;
966
968
 
967
 
  gimp_ui_init ("fits", FALSE);
 
969
  gimp_ui_init (PLUG_IN_BINARY, FALSE);
968
970
 
969
 
  dialog = gimp_dialog_new (_("Load FITS File"), "fits",
 
971
  dialog = gimp_dialog_new (_("Load FITS File"), PLUG_IN_BINARY,
970
972
                            NULL, 0,
971
 
                            gimp_standard_help_func, "file-fits-load",
 
973
                            gimp_standard_help_func, LOAD_PROC,
972
974
 
973
975
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
974
 
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,
 
976
                            GTK_STOCK_OPEN,   GTK_RESPONSE_OK,
975
977
 
976
978
                            NULL);
977
979
 
 
980
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
981
                                           GTK_RESPONSE_OK,
 
982
                                           GTK_RESPONSE_CANCEL,
 
983
                                           -1);
 
984
 
978
985
  vbox = gtk_vbox_new (FALSE, 12);
979
986
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
980
987
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox,
981
988
                      TRUE, TRUE, 0);
982
989
  gtk_widget_show (vbox);
983
990
 
984
 
  frame = gimp_int_radio_group_new (TRUE, _("BLANK/NaN Pixel Replacement"),
 
991
  frame = gimp_int_radio_group_new (TRUE, _("Replacement for undefined pixels"),
985
992
                                    G_CALLBACK (gimp_radio_button_update),
986
993
                                    &plvals.replace, plvals.replace,
987
994