예제 #1
0
func main() {
	flag.Parse()

	font, err := loadFont()
	if err != nil {
		log.Println(err)
		return
	}

	fontHeight := int(createContext(font).PointToFix32(*size) >> 8)
	// two points to output the text and its shadow
	ptA := freetype.Pt(*indent+1, *indent+1+fontHeight)
	ptB := freetype.Pt(*indent, *indent+fontHeight)

	proxy := goproxy.NewProxyHttpServer()
	proxy.OnResponse().Do(goproxy_image.HandleImage(func(img image.Image, ctx *goproxy.ProxyCtx) image.Image {
		outImage := image.NewRGBA(img.Bounds())
		draw.Copy(outImage, image.ZP, img, img.Bounds(), nil)
		text := fmt.Sprintf("%dx%d", img.Bounds().Dx(), img.Bounds().Dy())
		fontContext := createContext(font)
		fontContext.SetClip(img.Bounds())
		fontContext.SetDst(outImage)

		drawString(image.White, fontContext, ptA, text)
		drawString(image.Black, fontContext, ptB, text)

		return outImage
	}))
	proxy.Verbose = *verbose
	log.Fatal(http.ListenAndServe(":"+*port, proxy))
}
예제 #2
0
파일: main.go 프로젝트: BenPhegan/goproxy
func main() {
	proxy := goproxy.NewProxyHttpServer()
	proxy.OnResponse().Do(goproxy_image.HandleImage(func(img image.Image, ctx *goproxy.ProxyCtx) image.Image {
		dx, dy := img.Bounds().Dx(), img.Bounds().Dy()

		nimg := image.NewRGBA(img.Bounds())
		for i := 0; i < dx; i++ {
			for j := 0; j <= dy; j++ {
				nimg.Set(i, j, img.At(i, dy-j-1))
			}
		}
		return nimg
	}))
	proxy.Verbose = true
	log.Fatal(http.ListenAndServe(":8080", proxy))
}