Jump to content

Create a specific sized mask


Recommended Posts

I know is stupid but.

 

Need to create a mask such as the attached one.

 

The image size is . 1920x1080, the inside transparent rectangle need to be 1728x540, positioned 96, 108 pix from the upper left corner.

 

What I'm missing is how to define exactly the size of the drawed rectangle and his relative position.

post-141592-0-77186200-1433150510_thumb.

Link to comment
Share on other sites

Use the 'Rectangle Select' Tool.

 

In the status bar you can see the cursor position. Place the cursor at the start position and drag out the rectangle. The status bar tells you the size of the bounding rectangle while dragging. After releasing the mouse button at the right rectangle size press the Delete key to set the selection to transparent.

 

Use a zoom value >= 200% if it is difficult for you to place the cursor at the right poistion.

midoras signature.gif

Link to comment
Share on other sites

Thanks I did finally use Inkscape to obtain the same result.

 

A pity since Paint.net appear to be easier to obtain transparency and gradient effects, but I'm not able to fine control the position of this central rectangle.

 

Without a dialog box where I can set the relative position I did need to look at the numbers in the status bar and calculate the right offset from the rectangle center (I can't fine a way to calc it from one of the rectangle corners), simply didn't work.

Link to comment
Share on other sites

Select the Mask tool, then select Fixed Sized and make it the size you want. Select the white moving arrowhead and move it close to where you want it, then use the cursors to nudge it one pixel at a time until it's in the desired location. Set View to show pixels.

Link to comment
Share on other sites

Here is a CodeLab plugin called Rectangle Eraser that will erase a rectangle at a specified position and size: RectangleEraser.zip

It's in the Adjustment menu.
 

Here is the icon: post-53337-0-02045200-1433186662.png
Here is the source:

Hidden Content:
// Author: MJW
// Name: Rectangle Eraser
// Title: Rectangle Eraser
// Desc: Erase a rectangle of a specified position and size
// Keywords: erase rectangle
#region UICode
int Amount1 = 0; // [0,5000] X Position
int Amount2 = 0; // [0,5000] Y Position
int Amount3 = 100; // [1,5000] Width
int Amount4 = 100; // [1,5000] Height
#endregion


// Here is the main render loop function
void Render(Surface dst, Surface src, Rectangle rect)
{
    int startX = Amount1, startY = Amount2;
    int endX = startX + Amount3, endY = startY + Amount4;
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
        {
            dst[x, y] = ((x >= startX) && (y >= startY) && (x < endX) && (y < endY)) ?
                ColorBgra.Transparent : src[x, y];
        }
    }
}

Edited by MJW
  • Upvote 3
Link to comment
Share on other sites

I probably should mention that I post the source code (even as trivial as the code for this plugin) so that anyone who wants to, can use it for other plugins. If I post a plugin, and someone wants to make a better or fancier version, they can do so without asking, and with my blessing.,

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...