コード例 #1
0
ファイル: window.go プロジェクト: dylanpoe/golang.org
func handleUpload(hwnd win32.HWND, uMsg uint32, wParam, lParam uintptr) {
	id := wParam
	uploadsMu.Lock()
	u := uploads[id]
	delete(uploads, id)
	uploadsMu.Unlock()

	dc, err := win32.GetDC(hwnd)
	if err != nil {
		panic(err) // TODO handle errors
	}
	defer win32.ReleaseDC(hwnd, dc)

	u.src.preUpload(true)

	// TODO: adjust if dp is outside dst bounds, or sr is outside src bounds.
	err = blit(dc, _POINT{int32(u.dp.X), int32(u.dp.Y)}, u.src.hbitmap, &_RECT{
		Left:   int32(u.sr.Min.X),
		Top:    int32(u.sr.Min.Y),
		Right:  int32(u.sr.Max.X),
		Bottom: int32(u.sr.Max.Y),
	})
	go func() {
		u.src.postUpload()
		close(u.completion)
	}()
	if err != nil {
		panic(err) // TODO handle errors
	}
}
コード例 #2
0
ファイル: windraw.go プロジェクト: dylanpoe/golang.org
func fillSrc(hwnd win32.HWND, uMsg uint32, wParam, lParam uintptr) {
	dc, err := win32.GetDC(hwnd)
	if err != nil {
		panic(err) // TODO handle error?
	}
	defer win32.ReleaseDC(hwnd, dc)
	r := (*_RECT)(unsafe.Pointer(lParam))
	color := _COLORREF(wParam)

	// COLORREF is 0x00BBGGRR; color is 0xAARRGGBB
	color = _RGB(byte((color >> 16)), byte((color >> 8)), byte(color))
	brush, err := _CreateSolidBrush(color)
	if err != nil {
		panic(err) // TODO handle error
	}
	defer _DeleteObject(brush)
	err = _FillRect(dc, r, brush)
	if err != nil {
		panic(err) // TODO handle error
	}
}
コード例 #3
0
ファイル: windraw.go プロジェクト: dylanpoe/golang.org
func fillOver(hwnd win32.HWND, uMsg uint32, wParam, lParam uintptr) {
	dc, err := win32.GetDC(hwnd)
	if err != nil {
		panic(err) // TODO handle error
	}
	defer win32.ReleaseDC(hwnd, dc)
	r := (*_RECT)(unsafe.Pointer(lParam))
	color := _COLORREF(wParam)

	// AlphaBlend will stretch the input image (using StretchBlt's
	// COLORONCOLOR mode) to fill the output rectangle. Testing
	// this shows that the result appears to be the same as if we had
	// used a MxN bitmap instead.
	bitmap, bitvalues, err := mkbitmap(1, 1)
	if err != nil {
		panic(err) // TODO handle error
	}
	defer _DeleteObject(bitmap) // TODO handle error?
	*(*_COLORREF)(unsafe.Pointer(bitvalues)) = color
	if err = blend(dc, bitmap, r, 1, 1); err != nil {
		panic(err) // TODO handle error
	}
}