github.com/tcnksm/go@v0.0.0-20141208075154-439b32936367/doc/progs/image_package6.go (about)

     1  // cmpout
     2  
     3  // Copyright 2012 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package main
     8  
     9  import (
    10  	"fmt"
    11  	"image"
    12  )
    13  
    14  func main() {
    15  	m0 := image.NewRGBA(image.Rect(0, 0, 8, 5))
    16  	m1 := m0.SubImage(image.Rect(1, 2, 5, 5)).(*image.RGBA)
    17  	fmt.Println(m0.Bounds().Dx(), m1.Bounds().Dx()) // prints 8, 4
    18  	fmt.Println(m0.Stride == m1.Stride)             // prints true
    19  }