~ubuntu-branches/ubuntu/trusty/gimp/trusty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Ari Pollak
  • Date: 2009-08-14 09:57:17 UTC
  • mto: (1.1.21 upstream) (0.1.5 squeeze)
  • mto: This revision was merged to the branch mainline in revision 48.
  • Revision ID: james.westby@ubuntu.com-20090814095717-37dh2xqy5t0rurpk
ImportĀ upstreamĀ versionĀ 2.6.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <string.h>
28
28
 
29
29
#include <glib/gstdio.h>
 
30
#include <gdk-pixbuf/gdk-pixbuf.h>
30
31
 
31
32
#include <libgimp/gimp.h>
 
33
#include <libgimp/gimppixbuf.h>
32
34
 
33
35
#include "bmp.h"
34
36
 
367
369
    }
368
370
  else
369
371
    {
370
 
      g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
371
 
                   _("Error reading BMP file header from '%s'"),
372
 
                   gimp_filename_to_utf8 (filename));
373
 
      return -1;
 
372
      GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
 
373
 
 
374
      if (pixbuf)
 
375
        {
 
376
          gint32 layer_ID;
 
377
 
 
378
          image_ID = gimp_image_new (gdk_pixbuf_get_width (pixbuf),
 
379
                                     gdk_pixbuf_get_height (pixbuf),
 
380
                                     GIMP_RGB);
 
381
 
 
382
          layer_ID = gimp_layer_new_from_pixbuf (image_ID, _("Background"),
 
383
                                                 pixbuf,
 
384
                                                 100.,
 
385
                                                 GIMP_NORMAL_MODE, 0, 0);
 
386
          g_object_unref (pixbuf);
 
387
 
 
388
          gimp_image_set_filename (image_ID, filename);
 
389
          gimp_image_add_layer (image_ID, layer_ID, -1);
 
390
 
 
391
          return image_ID;
 
392
        }
 
393
      else
 
394
        {
 
395
 
 
396
          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
 
397
                       _("Error reading BMP file header from '%s'"),
 
398
                       gimp_filename_to_utf8 (filename));
 
399
          return -1;
 
400
        }
374
401
    }
375
402
 
376
403
  /* Valid bitpdepthis 1, 4, 8, 16, 24, 32 */