Gimp-developer] SoC: only two weeks left - hurry!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello everyone,

Sorry if this gets posted twice but my mail to the list hasn't been getting
posted.

I still want to finish up the healing brush and I have everything in order
except for one small problem.  I'll try and be as precise as possible in
describing it and hopefully I can get some help from the list.

First, what I do is get the area under the cursor and store it in tempPR like
this:

< code snippet>

  /* Get the area underneath the cursor */
  {
    GimpItem *item = GIMP_ITEM (drawable);
    TempBuf  *orig;
    gint      x1, x2, y1, y2;

    x1 = CLAMP (area->x, 0, gimp_item_width  (item));
    y1 = CLAMP (area->y, 0, gimp_item_height (item));
    x2 = CLAMP (area->x + area->width, 0, gimp_item_width   (item));
    y2 = CLAMP (area->y + area->height, 0, gimp_item_height (item));

    if (! (x2 - x1) || (! (y2 - y1)))
      return;

    orig = gimp_paint_core_get_orig_image (paint_core, drawable, x1, y1, x2,
y2);

    pixel_region_init_temp_buf (&srcPR, orig, 0, 0, x2 - x1, y2 - y1);
  }

  /* copy the area to tempPR */
  temp_data = g_malloc (srcPR.h * srcPR.bytes * srcPR.w);

  pixel_region_init_data (&tempPR,
                          temp_data,
                          srcPR.bytes,
                          srcPR.bytes * srcPR.w,
                          srcPR.x,
                          srcPR.y,
                          srcPR.w,
                          srcPR.h);

  copy_region (&srcPR, &tempPR);

< code snippet>

Then I perform all of the calculations and store them back in tempPR.  Then, I
get the location where the destination pixels are like this:

< code snippet>

  /* get the destination to paint to */
  pixel_region_init_temp_buf (&destPR, area, 0, 0, srcPR.w, srcPR.h);

< code snippet>

And what I want to do is copy the data from tempPR into destPR like this:

< code snippet>

 /* add an alpha region to the area if necessary */
  if (! gimp_drawable_has_alpha (drawable)) {
    add_alpha_region (&tempPR, &destPR);
  }
  else {
    copy_region (&tempPR, &destPR);
  }

< code snippet>

But after this call destPR doesn't reflect the contents of tempPR.  I think that
the problem stems from the call to pixel_regions_register called from within
copy_region.  If the pixel region is initialized using pixel_region_init_data
(like tempPR is) then the subsequent call to pixel_regions_register sets the
data pointer to an incorrect location.  Specifically, pixel_region_init_data
sets tempPR->data to the allocated memory, but then pixel_region_register sets
tempPR-> data to data + y*rowstride + x * bytes, which for this type of pixel
region is an error.

So, I guess my question is this:  If I have some data in a pixel region that has
been initialized using pixel_region_init_data, how can I copy that data into the
destination canvas?

Thanks a bunch,
Kevin

_______________________________________________
Gimp-developer mailing list
Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux