Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 11 for NewGray (0.15 sec)

  1. src/image/draw/example_test.go

    package draw_test
    
    import (
    	"fmt"
    	"image"
    	"image/color"
    	"image/draw"
    	"math"
    )
    
    func ExampleDrawer_floydSteinberg() {
    	const width = 130
    	const height = 50
    
    	im := image.NewGray(image.Rectangle{Max: image.Point{X: width, Y: height}})
    	for x := 0; x < width; x++ {
    		for y := 0; y < height; y++ {
    			dist := math.Sqrt(math.Pow(float64(x-width/2), 2)/3+math.Pow(float64(y-height/2), 2)) / (height / 1.5) * 255
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Jul 20 18:07:05 UTC 2023
    - 1.1K bytes
    - Viewed (0)
  2. src/image/image_test.go

    	for i := 0; i < b.N; i++ {
    		m.SetAlpha16(4, 5, c)
    	}
    }
    
    func BenchmarkGrayAt(b *testing.B) {
    	m := NewGray(Rect(0, 0, 10, 10))
    	b.ResetTimer()
    
    	for i := 0; i < b.N; i++ {
    		m.GrayAt(4, 5)
    	}
    }
    
    func BenchmarkGraySetGray(b *testing.B) {
    	m := NewGray(Rect(0, 0, 10, 10))
    	c := color.Gray{0x13}
    	b.ResetTimer()
    
    	for i := 0; i < b.N; i++ {
    		m.SetGray(4, 5, c)
    	}
    }
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Jun 30 02:00:49 UTC 2021
    - 10.8K bytes
    - Viewed (0)
  3. src/image/png/writer_test.go

    			if err != nil {
    				t.Fatal(err)
    			}
    			err = diff(convertToNRGBA(m0), m1)
    			if err != nil {
    				t.Error(err)
    			}
    		})
    	}
    }
    
    func BenchmarkEncodeGray(b *testing.B) {
    	img := image.NewGray(image.Rect(0, 0, 640, 480))
    	b.SetBytes(640 * 480 * 1)
    	b.ReportAllocs()
    	b.ResetTimer()
    	for i := 0; i < b.N; i++ {
    		Encode(io.Discard, img)
    	}
    }
    
    type pool struct {
    	b *EncoderBuffer
    }
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Oct 14 08:14:05 UTC 2022
    - 8.9K bytes
    - Viewed (0)
  4. src/image/draw/bench_test.go

    					uint8(13 * x % 0x100),
    					uint8(11 * y % 0x100),
    					uint8((11*x + 13*y) % 0x100),
    					uint8((31*x + 37*y) % 0x100),
    				})
    			}
    		}
    		src = src1
    	case color.GrayModel:
    		src1 := image.NewGray(image.Rect(0, 0, srcw, srch))
    		for y := 0; y < srch; y++ {
    			for x := 0; x < srcw; x++ {
    				src1.SetGray(x, y, color.Gray{
    					uint8((11*x + 13*y) % 0x100),
    				})
    			}
    		}
    		src = src1
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Jul 20 18:07:05 UTC 2023
    - 6.6K bytes
    - Viewed (0)
  5. src/image/jpeg/writer_test.go

    			continue
    		}
    	}
    }
    
    // TestWriteGrayscale tests that a grayscale images survives a round-trip
    // through encode/decode cycle.
    func TestWriteGrayscale(t *testing.T) {
    	m0 := image.NewGray(image.Rect(0, 0, 32, 32))
    	for i := range m0.Pix {
    		m0.Pix[i] = uint8(i)
    	}
    	var buf bytes.Buffer
    	if err := Encode(&buf, m0, nil); err != nil {
    		t.Fatal(err)
    	}
    	m1, err := Decode(&buf)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Sep 06 15:49:30 UTC 2022
    - 7.2K bytes
    - Viewed (0)
  6. src/image/jpeg/scan.go

    package jpeg
    
    import (
    	"image"
    )
    
    // makeImg allocates and initializes the destination image.
    func (d *decoder) makeImg(mxx, myy int) {
    	if d.nComp == 1 {
    		m := image.NewGray(image.Rect(0, 0, 8*mxx, 8*myy))
    		d.img1 = m.SubImage(image.Rect(0, 0, d.width, d.height)).(*image.Gray)
    		return
    	}
    
    	h0 := d.comp[0].h
    	v0 := d.comp[0].v
    	hRatio := h0 / d.comp[1].h
    	vRatio := v0 / d.comp[1].v
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Apr 25 00:46:29 UTC 2024
    - 15.7K bytes
    - Viewed (0)
  7. src/image/image.go

    		Stride: p.Stride,
    		Rect:   r,
    	}
    }
    
    // Opaque scans the entire image and reports whether it is fully opaque.
    func (p *Gray) Opaque() bool {
    	return true
    }
    
    // NewGray returns a new [Gray] image with the given bounds.
    func NewGray(r Rectangle) *Gray {
    	return &Gray{
    		Pix:    make([]uint8, pixelBufferLength(1, r, "Gray")),
    		Stride: 1 * r.Dx(),
    		Rect:   r,
    	}
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 12:02:45 UTC 2023
    - 34.9K bytes
    - Viewed (0)
  8. src/image/draw/draw_test.go

    	}
    	for y := 0; y < 16; y++ {
    		for x := 0; x < 16; x++ {
    			m.Cr[y*m.CStride+x] = uint8(y * 0x11)
    		}
    	}
    	return m
    }
    
    func vgradGray() image.Image {
    	m := image.NewGray(image.Rect(0, 0, 16, 16))
    	for y := 0; y < 16; y++ {
    		for x := 0; x < 16; x++ {
    			m.Set(x, y, color.Gray{uint8(y * 0x11)})
    		}
    	}
    	return m
    }
    
    func vgradMagenta() image.Image {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Jul 20 18:07:05 UTC 2023
    - 26K bytes
    - Viewed (0)
  9. src/image/png/reader.go

    	}
    	switch d.cb {
    	case cbG1, cbG2, cbG4, cbG8:
    		bitsPerPixel = d.depth
    		if d.useTransparent {
    			nrgba = image.NewNRGBA(image.Rect(0, 0, width, height))
    			img = nrgba
    		} else {
    			gray = image.NewGray(image.Rect(0, 0, width, height))
    			img = gray
    		}
    	case cbGA8:
    		bitsPerPixel = 16
    		nrgba = image.NewNRGBA(image.Rect(0, 0, width, height))
    		img = nrgba
    	case cbTC8:
    		bitsPerPixel = 24
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 12:02:45 UTC 2023
    - 26K bytes
    - Viewed (0)
  10. src/cmd/vendor/golang.org/x/tools/internal/stdlib/manifest.go

    		{"NYCbCrA", Type, 6},
    		{"NYCbCrA.A", Field, 6},
    		{"NYCbCrA.AStride", Field, 6},
    		{"NYCbCrA.YCbCr", Field, 6},
    		{"NewAlpha", Func, 0},
    		{"NewAlpha16", Func, 0},
    		{"NewCMYK", Func, 5},
    		{"NewGray", Func, 0},
    		{"NewGray16", Func, 0},
    		{"NewNRGBA", Func, 0},
    		{"NewNRGBA64", Func, 0},
    		{"NewNYCbCrA", Func, 6},
    		{"NewPaletted", Func, 0},
    		{"NewRGBA", Func, 0},
    		{"NewRGBA64", Func, 0},
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 02 02:20:05 UTC 2024
    - 534.2K bytes
    - Viewed (0)
Back to top