Ejemplo n.º 1
0
func createBitmap() *drawing.Bitmap {
	bounds := drawing.Rectangle{Width: 200, Height: 200}

	bmp, err := drawing.NewBitmap(bounds.Size())
	panicIfErr(err)

	surface, err := drawing.NewSurfaceFromImage(bmp)
	panicIfErr(err)
	defer surface.Dispose()

	brushBmp, err := drawing.NewBitmapFromFile("img/plus.png")
	panicIfErr(err)
	defer brushBmp.Dispose()

	brush, err := drawing.NewBitmapBrush(brushBmp)
	panicIfErr(err)
	defer brush.Dispose()

	panicIfErr(surface.FillRectangle(brush, bounds))

	font, err := drawing.NewFont("Times New Roman", 40, drawing.FontBold|drawing.FontItalic)
	panicIfErr(err)
	defer font.Dispose()

	panicIfErr(surface.DrawText("Runtime Created Bitmap", font, drawing.RGB(0, 0, 0), bounds, drawing.TextWordbreak))

	return bmp
}
Ejemplo n.º 2
0
func main() {
	runtime.LockOSThread()

	doc := printing.NewDocument("Walk Printing Example")
	defer doc.Dispose()

	doc.InsertPageBreak()

	text := "Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua."
	font, err := drawing.NewFont("Times New Roman", 12, 0)
	panicIfErr(err)
	color := drawing.RGB(0, 0, 0)
	preferredSize := drawing.Size{1000, 0}
	format := drawing.TextWordbreak

	for i := 0; i < 20; i++ {
		panicIfErr(doc.AddText(fmt.Sprintf("%d) %s", i, text), font, color, preferredSize, format))
	}

	panicIfErr(doc.Print())
}