This thread is closed due to being reported as solved. If you need it reopened, let us know. Thank you!
MV Cropping images from different sides
Learning JavascriptReopened at OP's request.
Just to have the info in one place, that part is not completely right.
I ran into this with one of my other plugins - there's a Window_Base.createContents() which resizes the (creates a new) contents bitmap based on the current width and height.
So, since I'm allowing user-provided images which I don't know the dimensions of ahead of time, I should be able to do (haven't tested it yet):
JavaScript:
let padding = Window_Base.prototype.standardPadding();
this._testGauge = new Window_Base();
this._testGauge.standardPadding = () => 0;
this._testGauge.padding = 0;
this.addChild(this._testGauge);
this._testGauge.opacity = 0;
this._testGauge._frame = new Sprite_Base();
this._testGauge._frame.bitmap = ImageManager.loadPicture("meter-frame");
this._testGauge.addChild(this._testGauge._frame);
this._testGauge.contentsWidth = () => this._testGauge._frame.bitmap.width;
this._testGauge.contentsHeight = () => this._testGauge._frame.bitmap.height;
this._testGauge.createContents();
Good point, remaking the bitmap is definitely an option I should have mentioned, what I wrote sounded more like it's some constant unchangeable thing. You can't resize it, but you absolutely can just replace it, the performance impact should be really small.
I can save you some debugging and point out that you can't access the width and height properties of an image until it has been loaded 😉
@Mac15001900 Fair enough! I just wanted that option included for posterity, in case anyone else comes across this trying to do the same insanity. Thanks again.
Closing for real this time.
Original thread: https://forums.rpgmakerweb.com/threads/cropping-images-from-different-sides.170163/