How to to weapon icon as bitmap

How do I get the weapon icon as bitmap?

I don't know how to get the bitmap after this

Code:
var bitmap = ImageManager.loadSystem('IconSet');var pw = Window_Base._iconWidth;var ph = Window_Base._iconHeight;var sx = iconIndex % 16 * pw;var sy = Math.floor(iconIndex / 16) * ph;
Take a look at how the base scripts do it:

Code:
Window_Base.prototype.drawIcon = function(iconIndex, x, y) {    var bitmap = ImageManager.loadSystem('IconSet');    var pw = Window_Base._iconWidth;    var ph = Window_Base._iconHeight;    var sx = iconIndex % 16 * pw;    var sy = Math.floor(iconIndex / 16) * ph;    this.contents.blt(bitmap, sx, sy, pw, ph, x, y);};
contents is defined here:
Code:
Window_Base.prototype.createContents = function() {    this.contents = new Bitmap(this.contentsWidth(), this.contentsHeight());    this.resetFontSettings();};
So, basically, you create a new bitmap with the dimensions you need and copy the icon over there ("blt" stands for "block transfer").

Original thread: https://forums.rpgmakerweb.com/threads/how-to-to-weapon-icon-as-bitmap.47795/