// int rbd_resize(rbd_image_t image, uint64_t size);
192309
func (image *Image) Resize(size uint64) error {
	if image.image == nil {
		return RbdErrorImageNotOpen
	}

	return GetError(C.rbd_resize(image.image, C.uint64_t(size)))
}
645521
func (cli *Client) ContainerResize(ctx context.Context, containerID string, options types.ResizeOptions) error {
	return cli.resize(ctx, "/containers/"+containerID, options.Height, options.Width)
}
1147376
func Resize(s string, length uint) string {
	n := int(length)
	if len(s) == n {
		return s
	}
	// Pads only when length of the string smaller than len needed
	s = PadRight(s, n, ' ')
	if len(s) > n {
		b := []byte(s)
		var buf bytes.Buffer
		for i := 0; i < n-3; i++ {
			buf.WriteByte(b[i])
		}
		buf.WriteString("...")
		s = buf.String()
	}
	return s
}
1084465
func DecodeRGBToSize(data []byte, width, height int) (m *RGBImage, err error) {
	pix, err := webpDecodeRGBToSize(data, width, height)
	if err != nil {
		return
	}
	m = &RGBImage{
		XPix:    pix,
		XStride: 3 * width,
		XRect:   image.Rect(0, 0, width, height),
	}
	return
}
76867
func convertImage(dest *Image, src image.Image) {
	var r, g, b, a uint32
	var x, y, i int

	for x = dest.Rect.Min.X; x < dest.Rect.Max.X; x++ {
		for y = dest.Rect.Min.Y; y < dest.Rect.Max.Y; y++ {
			r, g, b, a = src.At(x, y).RGBA()
			i = dest.PixOffset(x, y)
			dest.Pix[i+0] = uint8(b >> 8)
			dest.Pix[i+1] = uint8(g >> 8)
			dest.Pix[i+2] = uint8(r >> 8)
			dest.Pix[i+3] = uint8(a >> 8)
		}
	}
}
1216339
func rescale(im image.Image, sw, sh int) image.Image {
	b := im.Bounds()
	w, h := b.Dx(), b.Dy()
	if sw == w && sh == h {
		return im
	}

	// If it's gigantic, it's more efficient to downsample first
	// and then resize; resizing will smooth out the roughness.
	// (trusting the moustachio guys on that one).
	if w > sw*2 && h > sh*2 {
		im = resize.ResampleInplace(im, b, sw*2, sh*2)
		return resize.HalveInplace(im)
	}
	return resize.Resize(im, b, sw, sh)
}
756111
func ImageToNRGBA(img image.Image, width, height int) *image.NRGBA {
	newm := image.NewNRGBA(image.Rect(0, 0, width, height))
	draw.Draw(newm, newm.Bounds(), img, image.Point{0, 0}, draw.Src)

	return newm
}
364004
func resizeAndCrop(img image.Image, width, height int, anchor Anchor, filter ResampleFilter) *image.NRGBA {
	dstW, dstH := width, height

	srcBounds := img.Bounds()
	srcW := srcBounds.Dx()
	srcH := srcBounds.Dy()
	srcAspectRatio := float64(srcW) / float64(srcH)
	dstAspectRatio := float64(dstW) / float64(dstH)

	var tmp *image.NRGBA
	if srcAspectRatio < dstAspectRatio {
		tmp = Resize(img, dstW, 0, filter)
	} else {
		tmp = Resize(img, 0, dstH, filter)
	}

	return CropAnchor(tmp, dstW, dstH, anchor)
}
710755
func (p *Padder) Resize(size image.Point) {
	p.widget.Resize(size.Sub(p.padding.Mul(2)))
}
320782
func (s *service) ResizePty(ctx context.Context, r *taskAPI.ResizePtyRequest) (*ptypes.Empty, error) {
	return nil, errdefs.ErrNotImplemented
}
1087069
func (process *process) ResizeConsole(width, height uint16) error {
	return convertProcessError(process.p.ResizeConsole(width, height), process)
}
495848
func (t *LinodeService) Resize(linodeId int, planId int) (*LinodeResponse, error) {
	u := &url.Values{}
	u.Add("LinodeID", strconv.Itoa(linodeId))
	u.Add("PlanID", strconv.Itoa(planId))

	v := LinodeResponse{}
	if err := t.client.do("linode.resize", u, &v.Response); err != nil {
		return nil, err
	}

	v.LinodeId.LinodeId = linodeId // hardcode this to input
	return &v, nil
}
488540
func resizeYCbCr(m *image.YCbCr, r image.Rectangle, w, h int) (image.Image, bool) {
	dst := image.NewRGBA(image.Rect(0, 0, w, h))
	xdraw.ApproxBiLinear.Scale(dst, dst.Bounds(), m, m.Bounds(), xdraw.Src, nil)
	return dst, true
}
311203
func (c *Client) ResizeContainerTTY(id string, height, width int) error {
	params := make(url.Values)
	params.Set("h", strconv.Itoa(height))
	params.Set("w", strconv.Itoa(width))
	resp, err := c.do("POST", "/containers/"+id+"/resize?"+params.Encode(), doOptions{})
	if err != nil {
		return err
	}
	resp.Body.Close()
	return nil
}
741902
func (b *bitmap) size() uintptr {
	return uintptr(len(b.blocks)) * bmBlockWords * uintptrBytes
}
1188764
func RBDCreate(
	ctx types.Context,
	pool *string,
	image *string,
	sizeGB *int64,
	objectSize *string,
	features []*string) error {

	cmd := exec.Command(
		rbdCmd, "create", poolOpt, *pool,
		"--object-size", *objectSize,
		"--size", strconv.FormatInt(*sizeGB, 10)+"G",
	)

	for _, feature := range features {
		cmd.Args = append(cmd.Args, "--image-feature")
		cmd.Args = append(cmd.Args, *feature)
	}

	cmd.Args = append(cmd.Args, *image)
	_, _, err := RunCommand(ctx, cmd)
	if err != nil {
		return goof.WithError("unable to create rbd", err)
	}

	return nil
}
57184
func resizeRGBA(m *image.RGBA, r image.Rectangle, w, h int) image.Image {
	ww, hh := uint64(w), uint64(h)
	dx, dy := uint64(r.Dx()), uint64(r.Dy())
	// See comment in Resize.
	n, sum := dx*dy, make([]uint64, 4*w*h)
	for y := r.Min.Y; y < r.Max.Y; y++ {
		pix := m.Pix[(y-m.Rect.Min.Y)*m.Stride:]
		for x := r.Min.X; x < r.Max.X; x++ {
			// Get the source pixel.
			p := pix[(x-m.Rect.Min.X)*4:]
			r64 := uint64(p[0])
			g64 := uint64(p[1])
			b64 := uint64(p[2])
			a64 := uint64(p[3])
			// Spread the source pixel over 1 or more destination rows.
			py := uint64(y-r.Min.Y) * hh
			for remy := hh; remy > 0; {
				qy := dy - (py % dy)
				if qy > remy {
					qy = remy
				}
				// Spread the source pixel over 1 or more destination columns.
				px := uint64(x-r.Min.X) * ww
				index := 4 * ((py/dy)*ww + (px / dx))
				for remx := ww; remx > 0; {
					qx := dx - (px % dx)
					if qx > remx {
						qx = remx
					}
					qxy := qx * qy
					sum[index+0] += r64 * qxy
					sum[index+1] += g64 * qxy
					sum[index+2] += b64 * qxy
					sum[index+3] += a64 * qxy
					index += 4
					px += qx
					remx -= qx
				}
				py += qy
				remy -= qy
			}
		}
	}
	return average(sum, w, h, n)
}