Resize sets the size of the output image to given size. Does nothing if already the right size.
(sz image.Point)
| 116 | // Resize sets the size of the output image to given size. |
| 117 | // Does nothing if already the right size. |
| 118 | func (pt *Plot) Resize(sz image.Point) { |
| 119 | if pt.Pixels != nil { |
| 120 | ib := pt.Pixels.Bounds().Size() |
| 121 | if ib == sz { |
| 122 | pt.Size = sz |
| 123 | pt.Paint.UnitContext.DPI = pt.DPI |
| 124 | return // already good |
| 125 | } |
| 126 | } |
| 127 | pt.SetPixels(image.NewRGBA(image.Rectangle{Max: sz})) |
| 128 | } |
| 129 | |
| 130 | func (pt *Plot) SaveImage(filename string) error { |
| 131 | return imagex.Save(pt.Pixels, filename) |