Skip to content

Commit

Permalink
Merge pull request #5 from trajber/master
Browse files Browse the repository at this point in the history
provide a way to write PNG image file data to a buffer (byte array)
  • Loading branch information
bolknote committed Aug 10, 2015
2 parents 30ce83c + 3534362 commit a307a06
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions gd.go
Expand Up @@ -73,6 +73,17 @@ func ImageToJpegBuffer(p *Image, quality int) []byte {
return C.GoBytes(buf, *pimgSize)
}

func ImageToPngBuffer(p *Image) []byte {
var imgSize int
pimgSize := (*C.int)(Pointer(&imgSize))

buf := C.gdImagePngPtr(p.img, pimgSize)
defer C.gdFree(buf)

return C.GoBytes(buf, *pimgSize)
}


func CreateFromJpeg(infile string) *Image {
file := C.fopen(C.CString(infile), C.CString("rb"))

Expand Down

0 comments on commit a307a06

Please sign in to comment.