The Image Bounds function helps to determine the rectangular bounds of an image. This function is available in the image package in Go. This function returns a Rectangle structure that contains the dimensions of the image.
Example:
Let's say we have an image 'img' and we want to determine its bounds. We can do this by calling the Bounds() function as shown below:
import "image" bounds := img.Bounds()
This will return a Rectangle structure representing the image bounds. We can access the dimensions of this structure using its properties X, Y, Width, and Height.
Example:
In this example, we will create a new image with dimensions (300, 300). We will then call the Bounds() function to determine the bounds of the image.
In this example, we create a new image with dimensions (300, 300) using the NewRGBA() function. We then call the Bounds() function to determine the bounds of the image. Finally, we set the pixel at the bottom right corner (bounds.Max.X-1, bounds.Max.Y-1) to red using the Set() function.
Golang Image.Bounds - 30 examples found. These are the top rated real world Golang examples of image.Image.Bounds extracted from open source projects. You can rate examples to help us improve the quality of examples.