RSS/Atom feed Twitter
Site is read-only, email is disabled

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

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

1 of 1 message available
Toggle history

Please log in to manage your subscriptions.

Gimp-developer] SoC: only two weeks left - hurry! kbs464@mail.usask.ca 07 Aug 22:57
kbs464@mail.usask.ca
2006-08-07 22:57:21 UTC (over 17 years ago)

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

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