Esempio n. 1
0
// Refer win32 DrawText document for uFormat.
func (this *Canvas) DrawText(text string, rect *Rect, format uint, font *Font, textColor Color) {
	previousFont := w32.SelectObject(this.hdc, w32.HGDIOBJ(font.GetHFONT()))
	defer w32.SelectObject(this.hdc, w32.HGDIOBJ(previousFont))

	previousBkMode := w32.SetBkMode(this.hdc, w32.TRANSPARENT)
	defer w32.SetBkMode(this.hdc, previousBkMode)

	previousTextColor := w32.SetTextColor(this.hdc, w32.COLORREF(textColor))
	defer w32.SetTextColor(this.hdc, previousTextColor)

	w32.DrawText(this.hdc, text, len(text), rect.GetW32Rect(), format)
}
Esempio n. 2
0
// Rgb returns a rgb color
func rgb(c color.RGBA) w32.COLORREF {
	color := uint32(c.R) | (uint32(c.G) << 8) | (uint32(c.B) << 16)
	return w32.COLORREF(color)
}
Esempio n. 3
0
func setPixel(hdc w32.HDC, x, y int, color w32.COLORREF) w32.COLORREF {
	ret, _, _ := procSetPixel.Call(uintptr(hdc), uintptr(x), uintptr(y), uintptr(color))
	return w32.COLORREF(ret)
}