// NewPixbufFromData creates a Pixbuf from image data in a byte array
342558
func NewPixbufFromData(pbd PixbufData) *Pixbuf {
	gpixbuf := C.gdk_pixbuf_new_from_data(
		C.to_gucharptr(unsafe.Pointer(&pbd.Data[0])),
		C.GdkColorspace(pbd.Colorspace),
		gbool(pbd.HasAlpha),
		C.int(pbd.BitsPerSample),
		C.int(pbd.Width),
		C.int(pbd.Height),
		C.int(pbd.RowStride),
		nil, nil)
	return &Pixbuf{
		GdkPixbuf: &GdkPixbuf{gpixbuf},
		GObject:   glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
	}
}
419427
func PictureDataFromPicture(pic Picture) *PictureData {
	if pd, ok := pic.(*PictureData); ok {
		return pd
	}

	bounds := pic.Bounds()
	pd := MakePictureData(bounds)

	if pic, ok := pic.(PictureColor); ok {
		for y := math.Floor(bounds.Min.Y); y < bounds.Max.Y; y++ {
			for x := math.Floor(bounds.Min.X); x < bounds.Max.X; x++ {
				// this together with the Floor is a trick to get all of the pixels
				at := V(
					math.Max(x, bounds.Min.X),
					math.Max(y, bounds.Min.Y),
				)
				col := pic.Color(at)
				pd.Pix[pd.Index(at)] = color.RGBA{
					R: uint8(col.R * 255),
					G: uint8(col.G * 255),
					B: uint8(col.B * 255),
					A: uint8(col.A * 255),
				}
			}
		}
	}

	return pd
}
56652
func BitmapOf(dat ...uint32) *Bitmap {
	ans := NewBitmap()
	ans.AddMany(dat)
	return ans
}
777534
func (coff *Coff) AddData(symbol string, data Sizer) {
	coff.addSymbol(symbol)
	coff.Data = append(coff.Data, data)
	coff.SectionHeader32.SizeOfRawData += uint32(data.Size())
}
208537
func uintptrCFDataToBytes(cfData uintptr) ([]byte, error) {
	return C.GoBytes(unsafe.Pointer(C.CFDataGetBytePtrSafe(C.uintptr_t(cfData))), C.int(C.CFDataGetLengthSafe(C.uintptr_t(cfData)))), nil
}
1175651
func (d *DisplayBuffer) SetPixel(x, y, c int) {
	idx := x + (y/d.pageSize)*d.width
	bit := uint(y) % uint(d.pageSize)
	if c == 0 {
		d.buffer[idx] &= ^(1 << bit)
	} else {
		d.buffer[idx] |= (1 << bit)
	}
}
516955
func NewBitmapFromBlocks(blocks []Block) *Bitmap {
	return &Bitmap{size: len(blocks) * bitsPerBlock, store: blocks}
}
1281012
func NewPUBRECFromBytes(fixedHeader FixedHeader, variableHeader []byte) (Packet, error) {
	// Validate the byte data.
	if err := validatePUBRECBytes(fixedHeader, variableHeader); err != nil {
		return nil, err
	}

	// Decode the Packet Identifier.
	// No error occur because of the precedent validation and
	// the returned error is not be taken care of.
	packetID, _ := decodeUint16(variableHeader)

	// Create a PUBREC Packet.
	p := &PUBREC{
		PacketID: packetID,
	}

	// Set the fixed header to the Packet.
	p.fixedHeader = fixedHeader

	// Set the variable header to the Packet.
	p.variableHeader = variableHeader

	// Return the Packet.
	return p, nil
}
297062
func (c *ClientConn) SetPixelFormat(format *PixelFormat) error {
	var keyEvent [20]byte
	keyEvent[0] = 0

	pfBytes, err := writePixelFormat(format)
	if err != nil {
		return err
	}

	// Copy the pixel format bytes into the proper slice location
	copy(keyEvent[4:], pfBytes)

	// Send the data down the connection
	if _, err := c.c.Write(keyEvent[:]); err != nil {
		return err
	}

	// Reset the color map as according to RFC.
	var newColorMap [256]Color
	c.ColorMap = newColorMap

	return nil
}
623681
func NewImageBlock(imageURL, altText, blockID string, title *TextBlockObject) *ImageBlock {
	return &ImageBlock{
		Type:     mbtImage,
		ImageURL: imageURL,
		AltText:  altText,
		BlockID:  blockID,
		Title:    title,
	}
}
888613
func NewMultipartBuilder() MultipartBuilder {
	builder := MultipartBuilder{}
	var b bytes.Buffer
	builder.Buffer = &b
	builder.Writer = multipart.NewWriter(&b)
	return builder
}
139121
func NewVppAdapter() *VppAdapter {
	a := &VppAdapter{
		msgIDSeq:     1000,
		msgIDsToName: make(map[uint16]string),
		msgNameToIds: make(map[string]uint16),
		binAPITypes:  make(map[string]reflect.Type),
	}
	a.registerBinAPITypes()
	return a
}
959482
func XlibSurfaceCreateForBitmap(dpy unsafe.Pointer, bitmap uint64, screen unsafe.Pointer, width, height int) *XlibSurface {
	ret := &XlibSurface{wrapSurface(C.cairo_xlib_surface_create_for_bitmap((*C.Display)(dpy), C.Pixmap(bitmap), (*C.Screen)(screen), C.int(width), C.int(height)))}
	if err := ret.status(); err != nil {
		panic(err)
	}
	return ret
}
780649
func NewImageFromStock(stock_id string, size IconSize) *Image {
	ptr := C.CString(stock_id)
	defer cfree(ptr)
	return &Image{Misc{Widget{C.gtk_image_new_from_stock(gstring(ptr), C.GtkIconSize(size))}}}
}
135086
func pktsFromBytes(buff []byte) (pkts []ipPacket) {
  if buff[0] == 0x00 {
    n := buff[1]
    idx := 0
    for n > 0 {
      plen := binary.BigEndian.Uint16(buff[:2+idx])
      if 2 + int(plen) + idx < len(buff) {
        pkt := make([]byte, int(plen))
        copy(pkt, buff[idx+2:2+len(pkt)+idx])
        pkts = append(pkts, ipPacket(pkt))
        n--
        idx += len(pkt) + 2
      } else {
        return nil
      }
    }
  }
  return
}
486575
func NewBytes(X *xgbutil.XUtil, bs []byte) (*Image, error) {
	img, _, err := image.Decode(bytes.NewReader(bs))
	if err != nil {
		return nil, err
	}
	return NewConvert(X, img), nil
}
1050154
func NewBitmap(a ...uint64) *Bitmap {
	b := &Bitmap{
		Containers: newSliceContainers(),
	}
	// TODO: We have no way to report this. We aren't in a server context
	// so we haven't got a logger, nothing is checking for nil returns
	// from this...
	_, _ = b.AddN(a...)
	return b
}