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

« back to all changes in this revision

Viewing changes to plug-ins/common/compose.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-06 13:30:41 UTC
  • mto: This revision was merged to the branch mainline in revision 35.
  • Revision ID: james.westby@ubuntu.com-20081006133041-3panbkcanaymfsmp
Tags: upstream-2.6.0
ImportĀ upstreamĀ versionĀ 2.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
156
156
 
157
157
 
158
158
/* LAB colorspace constants */
159
 
const double Xn = 0.951;
160
 
const double Yn = 1.0;
161
 
const double Zn = 1.089;
 
159
static const double Xn  = 0.951;
 
160
static const double Yn  = 1.0;
 
161
static const double Zn  = 1.089;
162
162
 
163
163
/* Maximum number of images to compose */
164
164
#define MAX_COMPOSE_IMAGES 4
703
703
  /* Check image sizes */
704
704
  if (compose_by_drawable)
705
705
    {
706
 
      if (0 == gimp_drawable_bpp (inputs[first_ID].comp.ID))
 
706
      if (! gimp_drawable_is_valid (inputs[first_ID].comp.ID))
707
707
        {
708
 
          g_message (_("Specified layer %d not found"), inputs[first_ID].comp.ID);
 
708
          g_message (_("Specified layer %d not found"),
 
709
                     inputs[first_ID].comp.ID);
709
710
          return -1;
710
711
        }
711
712
 
716
717
        {
717
718
          if (inputs[j].is_ID)
718
719
            {
719
 
              if (0 == gimp_drawable_bpp (inputs[j].comp.ID))
 
720
              if (! gimp_drawable_is_valid (inputs[j].comp.ID))
720
721
                {
721
 
                  g_message (_("Specified layer %d not found"), inputs[j].comp.ID);
 
722
                  g_message (_("Specified layer %d not found"),
 
723
                             inputs[j].comp.ID);
722
724
                  return -1;
723
725
                }
724
726
 
761
763
        {
762
764
          if (inputs[j].is_ID)
763
765
            {
764
 
              gint32 *g32;
 
766
              gint32 *layers;
765
767
 
766
768
              /* Get first layer of image */
767
 
              g32 = gimp_image_get_layers (inputs[j].comp.ID, &num_layers);
768
 
              if ((g32 == NULL) || (num_layers <= 0))
 
769
              layers = gimp_image_get_layers (inputs[j].comp.ID, &num_layers);
 
770
 
 
771
              if (! layers || (num_layers <= 0))
769
772
                {
770
773
                  g_message (_("Error in getting layer IDs"));
771
774
                  return -1;
772
775
                }
773
776
 
774
777
              /* Get drawable for layer */
775
 
              drawable_src[j] = gimp_drawable_get (g32[0]);
776
 
              g_free (g32);
 
778
              drawable_src[j] = gimp_drawable_get (layers[0]);
 
779
              g_free (layers);
777
780
            }
778
781
        }
779
782
    }
782
785
  for (j = 0; j < num_images; j++)
783
786
    {
784
787
      gsize s;
 
788
 
785
789
      /* Check bytes per pixel */
786
790
      if (inputs[j].is_ID)
787
791
        {
788
792
          incr_src[j] = drawable_src[j]->bpp;
 
793
 
789
794
          if ((incr_src[j] != 1) && (incr_src[j] != 2))
790
795
            {
791
796
              g_message (_("Image is not a gray image (bpp=%d)"),
794
799
            }
795
800
 
796
801
          /* Get pixel region */
797
 
          gimp_pixel_rgn_init (&(pixel_rgn_src[j]), drawable_src[j], 0, 0,
 
802
          gimp_pixel_rgn_init (&pixel_rgn_src[j], drawable_src[j], 0, 0,
798
803
                               width, height, FALSE, FALSE);
799
804
        }
800
805
      else
801
806
        {
802
807
          incr_src[j] = 1;
803
808
        }
 
809
 
804
810
      /* Get memory for retrieving information */
805
811
      s = tile_height * width * incr_src[j];
806
812
      src[j] = g_new (guchar, s);
813
819
    {
814
820
      layer_ID_dst = composevals.source_layer_ID;
815
821
 
816
 
      if (0 == gimp_drawable_bpp (layer_ID_dst))
 
822
      if (! gimp_drawable_is_valid (layer_ID_dst))
817
823
        {
818
824
          g_message (_("Unable to recompose, source layer not found"));
819
825
          return -1;
820
826
        }
821
827
 
822
828
      drawable_dst = gimp_drawable_get (layer_ID_dst);
823
 
      gimp_pixel_rgn_init (&pixel_rgn_dst, drawable_dst, 0, 0,
824
 
                           drawable_dst->width,
825
 
                           drawable_dst->height,
 
829
      gimp_pixel_rgn_init (&pixel_rgn_dst, drawable_dst,
 
830
                           0, 0, drawable_dst->width, drawable_dst->height,
826
831
                           TRUE, TRUE);
827
 
      gimp_pixel_rgn_init (&pixel_rgn_dst_read, drawable_dst, 0, 0,
828
 
                           drawable_dst->width,
829
 
                           drawable_dst->height,
 
832
      gimp_pixel_rgn_init (&pixel_rgn_dst_read, drawable_dst,
 
833
                           0, 0, drawable_dst->width, drawable_dst->height,
830
834
                           FALSE, FALSE);
831
835
      image_ID_dst = gimp_drawable_get_image (layer_ID_dst);
832
836
    }