public static MySprite ResizeSpriteCanvas(MySprite Sprite, int newWidth, int newHeight, int horizontalAlignment, int verticalAlignment) { // Garbage in, garbage out if (Sprite == null || newWidth < 1 || newHeight < 1) { return(null); } // Create a new canvas to paint the original sprite to MyCanvas NewCanvas = new MyCanvas(newWidth, newHeight); // Compute the coordinates int posX = ComputePos(Sprite.width, newWidth, horizontalAlignment); int posY = ComputePos(Sprite.height, newHeight, verticalAlignment); // Draw the sprite onto the canvas NewCanvas.BitBlt(Sprite, posX, posY); // Return a new sprite with the data of a new canvas return(new MySprite(newWidth, newHeight, NewCanvas.GetBuffer())); }
public MyScreen WithCanvas(MyCanvas Canvas) { this.Canvas = Canvas; return(this); }