wailsapp/wails · error

StretchBlt failed

Error message

StretchBlt failed

What it means

Error "StretchBlt failed" thrown in wailsapp/wails.

Source

Thrown at v3/pkg/w32/gdi32.go:464

	return int(ret)
}

func StretchBlt(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int, dwRop uint) {
	ret, _, _ := procStretchBlt.Call(
		uintptr(hdcDest),
		uintptr(nXOriginDest),
		uintptr(nYOriginDest),
		uintptr(nWidthDest),
		uintptr(nHeightDest),
		uintptr(hdcSrc),
		uintptr(nXOriginSrc),
		uintptr(nYOriginSrc),
		uintptr(nWidthSrc),
		uintptr(nHeightSrc),
		uintptr(dwRop))

	if ret == 0 {
		panic("StretchBlt failed")
	}
}

func SetDIBitsToDevice(hdc HDC, xDest, yDest, dwWidth, dwHeight, xSrc, ySrc int, uStartScan, cScanLines uint, lpvBits []byte, lpbmi *BITMAPINFO, fuColorUse uint) int {
	ret, _, _ := procSetDIBitsToDevice.Call(
		uintptr(hdc),
		uintptr(xDest),
		uintptr(yDest),
		uintptr(dwWidth),
		uintptr(dwHeight),
		uintptr(xSrc),
		uintptr(ySrc),
		uintptr(uStartScan),
		uintptr(cScanLines),
		uintptr(unsafe.Pointer(&lpvBits[0])),
		uintptr(unsafe.Pointer(lpbmi)),
		uintptr(fuColorUse))

View on GitHub (pinned to 0e754b1b40)

Solutions

  1. Ensure both destination and source HDCs are valid and that the source DC has a bitmap selected before calling StretchBlt.
  2. Check that source and destination rectangles are non-empty and within bounds; zero or negative dimensions cause failure.
  3. Set a valid stretching mode with SetStretchBltMode on the destination DC before stretching when colors are combined.
  4. Verify the raster operation (dwRop) is supported by both device contexts.

When it happens

Trigger: Occurs when StretchBlt returns zero, e.g. invalid source/destination DC handles, invalid raster operation, or zero/negative dimensions causing an invalid stretch.

Common situations: See trigger scenarios.


AI-assisted analysis of wailsapp/wails@0e754b1b40 (2026-08-15). Data as JSON: /api/errors/8a6c14631716f46e. Report an issue: GitHub.