From 95316a1de5f76219da6cd23440a4ae6f17b987bf Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 18 Feb 2015 04:01:11 +0900 Subject: [PATCH] image: Cache size --- image.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/image.go b/image.go index beff017b0..eaa9c1d00 100644 --- a/image.go +++ b/image.go @@ -30,11 +30,16 @@ type Image struct { framebuffer *graphics.Framebuffer texture *graphics.Texture pixels []uint8 + width int + height int } // Size returns the size of the image. func (i *Image) Size() (width, height int) { - return i.framebuffer.Size() + if i.width == 0 { + i.width, i.height = i.framebuffer.Size() + } + return i.width, i.height } // Clear resets the pixels of the image into 0.