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

« back to all changes in this revision

Viewing changes to plug-ins/common/xwd.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
 * XWD reading and writing code Copyright (C) 1996 Peter Kirchgessner
4
4
 * (email: peter@kirchgessner.net, WWW: http://www.kirchgessner.net)
48
48
                          specified as big-endian). Trim magic header
49
49
 * V 1.95, PK, 02-Jul-01: Fix problem with 8 bit image
50
50
 */
51
 
static char ident[] = "@(#) GIMP XWD file-plugin v1.95  02-Jul-2001";
52
51
 
53
52
#include "config.h"
54
53
 
55
54
#include <errno.h>
56
 
#include <stdio.h>
57
 
#include <stdlib.h>
58
55
#include <string.h>
59
 
#ifdef HAVE_UNISTD_H
60
 
#include <unistd.h>
61
 
#endif
62
56
 
63
 
#include <gtk/gtk.h>
 
57
#include <glib/gstdio.h>
64
58
 
65
59
#include <libgimp/gimp.h>
66
60
#include <libgimp/gimpui.h>
68
62
#include "libgimp/stdplugins-intl.h"
69
63
 
70
64
 
 
65
#define LOAD_PROC      "file-xwd-load"
 
66
#define SAVE_PROC      "file-xwd-save"
 
67
#define PLUG_IN_BINARY "xwd"
 
68
 
 
69
 
71
70
typedef gulong  L_CARD32;
72
71
typedef gushort L_CARD16;
73
72
typedef guchar  L_CARD8;
225
224
                              gint32);
226
225
 
227
226
 
228
 
GimpPlugInInfo PLUG_IN_INFO =
 
227
const GimpPlugInInfo PLUG_IN_INFO =
229
228
{
230
229
  NULL,  /* init_proc  */
231
230
  NULL,  /* quit_proc  */
245
244
query (void)
246
245
 
247
246
{
248
 
  static GimpParamDef load_args[] =
 
247
  static const GimpParamDef load_args[] =
249
248
  {
250
 
    { GIMP_PDB_INT32,  "run_mode",     "Interactive, non-interactive" },
 
249
    { GIMP_PDB_INT32,  "run-mode",     "Interactive, non-interactive" },
251
250
    { GIMP_PDB_STRING, "filename",     "The name of the file to load" },
252
 
    { GIMP_PDB_STRING, "raw_filename", "The name of the file to load" }
 
251
    { GIMP_PDB_STRING, "raw-filename", "The name of the file to load" }
253
252
  };
254
253
 
255
 
  static GimpParamDef load_return_vals[] =
 
254
  static const GimpParamDef load_return_vals[] =
256
255
  {
257
256
    { GIMP_PDB_IMAGE,  "image",        "Output image" }
258
257
  };
259
258
 
260
 
  static GimpParamDef save_args[] =
 
259
  static const GimpParamDef save_args[] =
261
260
  {
262
 
    { GIMP_PDB_INT32,    "run_mode",     "Interactive, non-interactive" },
 
261
    { GIMP_PDB_INT32,    "run-mode",     "Interactive, non-interactive" },
263
262
    { GIMP_PDB_IMAGE,    "image",        "Input image" },
264
263
    { GIMP_PDB_DRAWABLE, "drawable",     "Drawable to save" },
265
264
    { GIMP_PDB_STRING,   "filename",     "The name of the file to save the image in" },
266
 
    { GIMP_PDB_STRING,   "raw_filename", "The name of the file to save the image in" }
 
265
    { GIMP_PDB_STRING,   "raw-filename", "The name of the file to save the image in" }
267
266
  };
268
267
 
269
 
  gimp_install_procedure ("file_xwd_load",
 
268
  gimp_install_procedure (LOAD_PROC,
270
269
                          "Loads files in the XWD (X Window Dump) format",
271
270
                          "Loads files in the XWD (X Window Dump) format. "
272
271
                          "XWD image files are produced by the program xwd. "
281
280
                          G_N_ELEMENTS (load_return_vals),
282
281
                          load_args, load_return_vals);
283
282
 
284
 
  gimp_register_file_handler_mime ("file_xwd_load", "image/x-xwindowdump");
285
 
  gimp_register_magic_load_handler ("file_xwd_load",
 
283
  gimp_register_file_handler_mime (LOAD_PROC, "image/x-xwindowdump");
 
284
  gimp_register_magic_load_handler (LOAD_PROC,
286
285
                                    "xwd",
287
286
                                    "",
288
287
                                    "4,long,0x00000007");
289
288
 
290
 
  gimp_install_procedure ("file_xwd_save",
 
289
  gimp_install_procedure (SAVE_PROC,
291
290
                          "Saves files in the XWD (X Window Dump) format",
292
291
                          "XWD saving handles all image types except "
293
292
                          "those with alpha channels.",
300
299
                          G_N_ELEMENTS (save_args), 0,
301
300
                          save_args, NULL);
302
301
 
303
 
  gimp_register_file_handler_mime ("file_xwd_save", "image/x-xwindowdump");
304
 
  gimp_register_save_handler ("file_xwd_save", "xwd", "");
 
302
  gimp_register_file_handler_mime (SAVE_PROC, "image/x-xwindowdump");
 
303
  gimp_register_save_handler (SAVE_PROC, "xwd", "");
305
304
}
306
305
 
307
306
 
329
328
  values[0].type          = GIMP_PDB_STATUS;
330
329
  values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
331
330
 
332
 
  if (strcmp (name, "file_xwd_load") == 0)
 
331
  if (strcmp (name, LOAD_PROC) == 0)
333
332
    {
334
333
      image_ID = load_image (param[1].data.d_string);
335
334
 
344
343
          status = GIMP_PDB_EXECUTION_ERROR;
345
344
        }
346
345
    }
347
 
  else if (strcmp (name, "file_xwd_save") == 0)
 
346
  else if (strcmp (name, SAVE_PROC) == 0)
348
347
    {
349
348
      image_ID    = param[1].data.d_int32;
350
349
      drawable_ID = param[2].data.d_int32;
354
353
        {
355
354
        case GIMP_RUN_INTERACTIVE:
356
355
        case GIMP_RUN_WITH_LAST_VALS:
357
 
          gimp_ui_init ("xwd", FALSE);
 
356
          gimp_ui_init (PLUG_IN_BINARY, FALSE);
358
357
          export = gimp_export_image (&image_ID, &drawable_ID, "XWD",
359
358
                                      (GIMP_EXPORT_CAN_HANDLE_RGB |
360
359
                                       GIMP_EXPORT_CAN_HANDLE_GRAY |
411
410
{
412
411
  FILE            *ifp;
413
412
  gint             depth, bpp;
414
 
  gchar           *temp;
415
413
  gint32           image_ID;
416
414
  L_XWDFILEHEADER  xwdhdr;
417
415
  L_XWDCOLOR      *xwdcolmap = NULL;
418
416
 
419
 
  ifp = fopen (filename, "rb");
 
417
  ifp = g_fopen (filename, "rb");
420
418
  if (!ifp)
421
419
    {
422
420
      g_message (_("Could not open '%s' for reading: %s"),
472
470
        }
473
471
    }
474
472
 
475
 
  temp = g_strdup_printf (_("Opening '%s'..."),
476
 
                          gimp_filename_to_utf8 (filename));
477
 
  gimp_progress_init (temp);
478
 
  g_free (temp);
 
473
  gimp_progress_init_printf (_("Opening '%s'"),
 
474
                             gimp_filename_to_utf8 (filename));
479
475
 
480
476
  depth = xwdhdr.l_pixmap_depth;
481
477
  bpp   = xwdhdr.l_bits_per_pixel;
523
519
    g_free (xwdcolmap);
524
520
 
525
521
  if (image_ID == -1)
526
 
    {
527
 
      temp = g_strdup_printf (_("XWD-file %s has format %d, depth %d\n"
528
 
                                "and bits per pixel %d.\n"
529
 
                                "Currently this is not supported."),
530
 
                              gimp_filename_to_utf8 (filename),
531
 
                              (gint) xwdhdr.l_pixmap_format, depth, bpp);
532
 
      g_message (temp);
533
 
      g_free (temp);
534
 
 
535
 
      return -1;
536
 
    }
 
522
    g_message (_("XWD-file %s has format %d, depth %d and bits per pixel %d. "
 
523
                 "Currently this is not supported."),
 
524
               gimp_filename_to_utf8 (filename),
 
525
               (gint) xwdhdr.l_pixmap_format, depth, bpp);
537
526
 
538
527
  return image_ID;
539
528
}
547
536
  FILE          *ofp;
548
537
  GimpImageType  drawable_type;
549
538
  gint           retval;
550
 
  gchar         *temp;
551
539
 
552
540
  drawable_type = gimp_drawable_type (drawable_ID);
553
541
 
571
559
    }
572
560
 
573
561
  /* Open the output file. */
574
 
  ofp = fopen (filename, "wb");
 
562
  ofp = g_fopen (filename, "wb");
575
563
  if (!ofp)
576
564
    {
577
565
      g_message (_("Could not open '%s' for writing: %s"),
579
567
      return FALSE;
580
568
    }
581
569
 
582
 
  temp = g_strdup_printf (_("Saving '%s'..."),
583
 
                          gimp_filename_to_utf8 (filename));
584
 
  gimp_progress_init (temp);
585
 
  g_free (temp);
 
570
  gimp_progress_init_printf (_("Saving '%s'"),
 
571
                             gimp_filename_to_utf8 (filename));
586
572
 
587
573
  if (drawable_type == GIMP_INDEXED_IMAGE)
588
574
    retval = save_index (ofp, image_ID, drawable_ID, 0);
1185
1171
  guchar           c1, c2, c3, c4;
1186
1172
  gint             width, height, linepad, scan_lines, tile_height;
1187
1173
  gint             i, j, ncols;
1188
 
  gchar           *temp = ident;  /* Just to satisfy lint/gcc */
 
1174
  gchar           *temp;
1189
1175
  guchar           bit2byte[256 * 8];
1190
1176
  guchar          *data, *scanline;
1191
1177
  gint             err = 0;