MZ [SOLVED] How to load a picture inside a window?

I've read through this from the thead (How to display an image in a window?):
JavaScript:
Window_Base.prototype.drawPicture = function(filename, x, y) {
var bitmap = ImageManager.loadPicture(filename);   
this.contents.blt(bitmap, 0, 0, bitmap._canvas.width, bitmap._canvas.height, x, y); 
};
but can't figure out how to convert it to MZ.

As javascript is new to me it's probably something silly easy, so any help is highly appreciated.
Hi there!
I believe it's the same thing. But I will do it a little different:

JavaScript:
Window_Base.prototype.drawPicture = function(filename, x, y) {
    const bitmap = ImageManager.loadPicture(filename) // This will load the filename inside the Img/pictures folder
    bitmap.addLoadListener(() => { // This is a method that will run a callback when the bitmap is loaded
        this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, x, y) // This will draw the bitmap on the contents of the window.
    })
};
Thanks for the quick reply Eliaquim!
It works now

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-how-to-load-a-picture-inside-a-window.142124/