MZ How to make the picture drawn in the window content be cut by the border?

Hi everyone, I'm trying to make a picture I draw in a window get clipped by the window's borders.

My window uses the code below, but the picture is displayed in the window in a smaller way, it is some distance from the border of the window.
JavaScript:
class Window_ThumbnailView extends Window_Base {
   
    constructor() {
        const rect = {
            x: 452,
            y: 262,
            width: 552,
            height: 312
        }
        super(rect)
    }

    drawPicture(filename, x, y) {
        const bitmap = ImageManager.loadParallax(filename)
        bitmap.addLoadListener(() => {
            this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, x, y, this.contents.width, this.contents.height)
        })
    };

}

image.png


I draw using drawPicture("pictureName", 0, 0), I tried modifying the parameters of this.contents.blt(Like changing this.contents.width to this.width), but it didn't seem to work, please give me some advice.
contents covers the window's standard display area, within its border. This area has a margin (default 12 px) to leave space for the border. The border's appearance is determined by the windowskin. In case you're interested, this post has more details about the windowskin:
I think you could edit the windowskin for your game (or find a pre-made replacement) to make the border come right up to the edge of the content.

If you want to place your image so it overlaps the frame/border, consider a different approach. E.g. you could make a new Sprite instance and add it as a new child to the game window.
contents covers the window's standard display area, within its border. This area has a margin (default 12 px) to leave space for the border. The border's appearance is determined by the windowskin. In case you're interested, this post has more details about the windowskin:
I think you could edit the windowskin for your game (or find a pre-made replacement) to make the border come right up to the edge of the content.

If you want to place your image so it overlaps the frame/border, consider a different approach. E.g. you could make a new Sprite instance and add it as a new child to the game window.
Hello, thank you for your reply, I will try your method.

EDIT: Just giving an update on my progress in case anyone needs it.

I set the Window's _padding value to 0, and set the return values of contentsWidth() and contentsHeigh() to the Window's width and height.
JavaScript:
this._padding = 0

// overwrite Window class's method
contentsWidth() {
        return this.width
}

contentsHeight() {
        return this.height
}

Then your contents and window have the same size and you can start drawing your image inside _clientArea's _contentsSprite.
JavaScript:
const bitmap = ImageManager.loadParallax(filename)
bitmap.addLoadListener(() => {
    this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, this._margin, this._margin, this.width - 2 * this._margin, this.height - 2 * this._margin)
})
_margin is used here because you need to limit the image to within _frameSprite, so just set the size and position of the drawn image to the same as _backSprite.

Finally, add a default rounded frame to your _clientArea and remove the _container's frame. Of course, you don’t have to remove it, but this way there will be two frames, although it looks like there is only one.
JavaScript:
this._container.removeChild(this._frameSprite)
this._clientArea.addChild(this._frameSprite)

Okay, now it looks like the image of the window has been cut with rounded corners.

test.png

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-the-picture-drawn-in-the-window-content-be-cut-by-the-border.161298/