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

gimp_pixel_rgn_resize help

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.

8 of 11 messages available
Toggle history

Please log in to manage your subscriptions.

gimp_pixel_rgn_resize help Brohan 02 Aug 23:57
  gimp_pixel_rgn_resize help Sven Neumann 08 Aug 10:09
gimp_pixel_rgn_resize help Brohan 10 Aug 19:29
  gimp_pixel_rgn_resize help Sven Neumann 10 Aug 19:31
   gimp_pixel_rgn_resize help Brohan 10 Aug 22:19
de11b33c0608080717r4ccdddb8... 07 Oct 20:24
  gimp_pixel_rgn_resize help Sven Neumann 08 Aug 16:33
de11b33c0608080836o41a6e8a7... 07 Oct 20:24
  gimp_pixel_rgn_resize help Sven Neumann 08 Aug 18:44
de11b33c0608081402s1d557084... 07 Oct 20:24
  gimp_pixel_rgn_resize help Sven Neumann 10 Aug 09:41
Brohan
2006-08-02 23:57:12 UTC (over 17 years ago)

gimp_pixel_rgn_resize help

Hi everyone,

I'm building a plugin to compare two images side-by-side with panning and zooming, and I'm having a bit of an issue with getting the zooming to work.

The way I'm doing it is initalizing a pixel region with the width being (width of preview) / (zoom factor) and soforth.

/* Snip */ map_1 = gimp_drawable_get (vals.map_id_1); gimp_pixel_rgn_init (&map_1_rgn, map_1, p1_x1, p1_y1, init_width, init_height, FALSE, FALSE);
gimp_pixel_rgn_resize ( &map_1_rgn , p1_x1, p1_y1, p1_width, p1_height); gimp_drawable_preview_draw_region (GIMP_DRAWABLE_PREVIEW (preview), &map_1_rgn); /'* Snap */

p1_x1, p1_y1 are the coordinates of the top left point, p1_width and p1_height are the width and height of the preview window, init_width and init_height are the smaller coordinates of the pixel region that have been divided by the zoom factor.

This isn't even close to working, and after going through the API documentation several times and gdb equally, I'm sure its being called, the only problem is that it isn't doing anything, it would be the same as initializing the region with the width and height of the preview pane.

Thanks,
Brohan

Sven Neumann
2006-08-08 10:09:05 UTC (over 17 years ago)

gimp_pixel_rgn_resize help

Hi,

On Wed, 2006-08-02 at 17:57 -0400, Brohan wrote:

I'm building a plugin to compare two images side-by-side with panning and zooming, and I'm having a bit of an issue with getting the zooming to work.

The way I'm doing it is initalizing a pixel region with the width being (width of preview) / (zoom factor) and soforth.

/* Snip */ map_1 = gimp_drawable_get (vals.map_id_1); gimp_pixel_rgn_init (&map_1_rgn, map_1, p1_x1, p1_y1, init_width, init_height, FALSE, FALSE);
gimp_pixel_rgn_resize ( &map_1_rgn , p1_x1, p1_y1, p1_width, p1_height); gimp_drawable_preview_draw_region (GIMP_DRAWABLE_PREVIEW (preview), &map_1_rgn); /'* Snap */

What do you expect gimp_pixel_rgn_resize() to do? It doesn't do any scaling if that is what you are trying to achieve.

Sven

Sven Neumann
2006-08-08 16:33:58 UTC (over 17 years ago)

gimp_pixel_rgn_resize help

Hi,

On Tue, 2006-08-08 at 10:17 -0400, Brohan wrote:

Ah, I expected it to do any scaling. Are there any library functions that do do scaling? I was expecting gimp_pixel_rgn_resize() to do the scaling, as resizing the pixel region might entail scaling.

Resizing in GIMP terms usually just means to change the dimensions, without touching the pixel data. That is the case here as well.

On a side note, is there a way to create an empty pixel region that is not attached to a drawable, or create a drawable that a pixel region can attach to? (This is to dump the scaled thing onto)

No there isn't. And you should make yourself clear that the drawable only exists in the GIMP core. If your pixel data is in the plug-in, you can't simply attach it, it needs to be copied to the core.

If you need a scaled down version of the drawable, you may want to use gimp_drawable_get_thumbnail_data(). Or use a GimpZoomPreview.

Sven

Sven Neumann
2006-08-08 18:44:36 UTC (over 17 years ago)

gimp_pixel_rgn_resize help

Hi,

On Tue, 2006-08-08 at 11:36 -0400, Brohan wrote:

Ah, its a scaled *up* picture that I need. The problem with GimpZoomPreivew (And I have looked into it), is that there's no way to get the zoom factor to set on another preview.

There's gimp_zoom_preview_get_factor() for this purpose.

A tiny little source dive didn't pick up any GimpZoomPreview functions, could you point me to where they are. There's nothing indicative of it in ./libgimpwidgets, nor in any of the preview .c's there. I'm running gimp-2.2.12 and using that source.

GimpZoomPreview is not in GIMP 2.2, it will be part of the GIMP 2.4 API.

Sven

PS: Please try to reply to the list also. Others might want to benefit from our discussion as well.

Sven Neumann
2006-08-10 09:41:59 UTC (over 17 years ago)

gimp_pixel_rgn_resize help

Hi,

On Tue, 2006-08-08 at 17:02 -0400, Brohan wrote:

I'm well aware of gimp_zoom_preview_get_factor(), but there isn't a matching fuction such as gimp_zoom_preview_set_factor().

I have changed the API a little now, introducing a way to get access to the GimpZoomModel that is being used by the preview widget. There is also a new constructor gimp_zoom_preview_new_with_model() that takes a GimpZoomModel parameter. That way you can have two previews sharing the same zoom model, thus always using the scale factor.

I might look into using the 2.4 API, or extending GimpZoomPreview to add gimp_zoom_preview_set_factor() or something. Though using a nonstable and nonstandard version may hamper usability of my plugin. It is intended to be a lab tool for my uni, however it wouldn't be nice to ask the sysadmin to make a package out of 2.4 and distrubute it, it took some begging to get the gimp developer toolset on the install.

I am not suggesting that you do that. Until 2.4 is actually released, the new APIs are still subject to changes and there are also still bugs lurking in the code.

Sven

Brohan
2006-08-10 19:29:44 UTC (over 17 years ago)

gimp_pixel_rgn_resize help

I'm sorry for not writing this to the mailing list, my client settings are a bit funky and had me writing emails only to Sven. Sorry :|

Hi,

On Tue, 2006-08-08 at 17:02 -0400, Brohan wrote:

I'm well aware of gimp_zoom_preview_get_factor(), but there isn't a matching fuction such as gimp_zoom_preview_set_factor().

I have changed the API a little now, introducing a way to get access to the GimpZoomModel that is being used by the preview widget. There is also a new constructor gimp_zoom_preview_new_with_model() that takes a GimpZoomModel parameter. That way you can have two previews sharing the same zoom model, thus always using the scale factor.

Great work, thanks for doing this :)

I'm still having the same issue as before with the same error as before.

"(gimp:26837): Gimp-Plug-In-WARNING **: expected tile ack and received: 5"

I've ran gdb and set every possible breakpoint and it always says that the program 'exits' normally. I'm beginning to dive into the source and its rather difficult to pull stuff out.

The issue happens when a) I zoom in/out and move around,
b) I zoom in/out twice.

I am sure the issue does not happen within the main loop of my actual code, but possibly within the preview. I've set static local variables in a struct as the drawable ID's of what I am working in.

So, foo = gimp_drawable_preview(gimp_drawable_get(drawable_index.drawable_1), &bar.preview_bool);

I think there may be some issue with sizing in there, causing something to go terribly wrong. In either case, I don't think any of my code is executing. Is there any route I should specifically go down to get some sort of scaling functionality. I've been contemplating just doing something manually with operations on the pixel region.

Thanks, brohan

Sven Neumann
2006-08-10 19:31:45 UTC (over 17 years ago)

gimp_pixel_rgn_resize help

Hi,

On Thu, 2006-08-10 at 13:29 -0400, Brohan wrote:

I'm still having the same issue as before with the same error as before.

"(gimp:26837): Gimp-Plug-In-WARNING **: expected tile ack and received: 5"

I've ran gdb and set every possible breakpoint and it always says that the program 'exits' normally. I'm beginning to dive into the source and its rather difficult to pull stuff out.

You should be able to debug this by using the GIMP_PLUGIN_DEBUG environment variable as described in devel-docs/debug-plug-ins.txt.

The issue happens when
a) I zoom in/out and move around,
b) I zoom in/out twice.

I am sure the issue does not happen within the main loop of my actual code, but possibly within the preview.

Please try to make a self-contained and possibly small test-case, then show us this code. It doesn't make much sense to discuss this w/o seeing the code.

Sven

Brohan
2006-08-10 22:19:02 UTC (over 17 years ago)

gimp_pixel_rgn_resize help

Thanks for your attention, I've got a case all written up.

http://cim.mcgill.ca/~brohan/compare-case.tar.gz

Its as small as I could make it, it does have a lot of GTK junk to get all the stuff together.

It makes the same errors as my plugin, to reiterate; to make it crash you can a) Zoom in/out and move around
b) Zoom in/out and zoom in the opposite direction again.

I didn't include the code to make the image back to normal at the end, so the layer will stay resized :/

Thanks, brohan