Giter VIP home page Giter VIP logo

Comments (3)

bbbbbr avatar bbbbbr commented on May 26, 2024

The Scaler mode selects both the algorithm and the scaling factor (see list of values below). The scaling factor and the input image resolution determine the output image resolution (input width * scale factor = output width).

https://github.com/bbbbbr/gimp-plugin-pixel-art-scalers/blob/master/src/filter_scalers.h#L43
I've added comments here for readbility in the enum

    enum scaler_list {
        SCALER_ENUM_FIRST = 0,

        SCALER_2X_HQX = SCALER_ENUM_FIRST, // 0
        SCALER_2X_XBR, // 1
        SCALER_2X_SCALEX, // 2
        SCALER_2X_NEAREST, // 3

        SCALER_3X_HQX, // 4
        SCALER_3X_XBR, // 5
        SCALER_3X_SCALEX, // 6
        SCALER_3X_NEAREST, // 7

        SCALER_4X_HQX,  // 8
        SCALER_4X_XBR,  // 9
        SCALER_4X_SCALEX,  // 10
        SCALER_4X_NEAREST,  // 11

        SCALER_ENUM_LAST
    };

As for the size- I think what you're seeing (and what I saw when I tested) is that the plugin is able to resize the image, but for some reason the drawable (layer) area appears to get clipped in BIMP unlike under normal plugin operation.

So it can create the larger image, but you only get to see the upscaled output for the region which matches the area from the original image (1/4 of the output image size if you're doing 2x, 1/9 of the output image if doing 3x, etc).

This is the code where it performs the output image resize:
https://github.com/bbbbbr/gimp-plugin-pixel-art-scalers/blob/master/src/filter_dialog.c#L666

Here is where it gets called in BIMP:
https://github.com/alessandrofrancesconi/gimp-plugin-bimp/blob/master/src/bimp-operate.c#L942

It's not clear to me where the problem is. The pixel art plugin works under normal operation, so something must be different in how it gets called under BIMP.

What is interesting is that after BIMP runs it, gimp_drawable_width() and height (new scaled size) no longer match the output of gimp_drawable_mask_intersect() (non-scaled size).

	gint width, height, x, y;
	gboolean result;
    result = gimp_drawable_mask_intersect (gimp_image_get_active_drawable(out->image_id), &x, &y, &width, &height);
    g_print("%d, %d  %dx%d = %d\n", x, y, width, height, result);
    g_print("%dx%d\n", gimp_drawable_width(gimp_image_get_active_drawable(out->image_id)), 
								gimp_drawable_height(gimp_image_get_active_drawable(out->image_id)));

output for a source 33 x 20 image
0, 0  33x20 = 1
66x40

from gimp-plugin-pixel-art-scalers.

bbbbbr avatar bbbbbr commented on May 26, 2024

Actually, I think I found the problem and a solution (in changing BIMP).

In the BIMP source code it seems to set the selection to "All" of the image right before calling my plugin.

  int single_drawable = gimp_image_merge_visible_layers(out->image_id, GIMP_CLIP_TO_IMAGE);
	gimp_selection_all(out->image_id);

https://github.com/alessandrofrancesconi/gimp-plugin-bimp/blob/master/src/bimp-operate.c#L951

But since it does that, the plugin is going to try and honor the selection area and only operate within it (as is typical for most plugins). And the selection area does not grow to match the resized image (since my plugin resizes the image but doesn't rescale the underlying image since the user may not want that for all layers).

If I change the BIMP source code to select NONE, then the full scaled images show up in the output. It's not clear to me whether the use of gimp_selection_all() instead of gimp_selection_none is intentional or not.

  int single_drawable = gimp_image_merge_visible_layers(out->image_id, GIMP_CLIP_TO_IMAGE);
	gimp_selection_none(out->image_id);

from gimp-plugin-pixel-art-scalers.

bbbbbr avatar bbbbbr commented on May 26, 2024

The changes to BIMP for compatibility have been merged, so you should be able to use it with this plugin whenever they release the next build that includes PR # 313 there.

from gimp-plugin-pixel-art-scalers.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.