You always need a window. The trick is to make the window look like it’s nothing but the sprite. There are three parts to it:
- Creating a window the same size as your sprite.
- Asking the OS (Windows, macOS, Linux, etc.) to give you a window with no titlebar or borders. (Like things like WinAMP did.)
- Setting the shape mask.
(The shape mask is like GIF transparency. It lets you specify that part of the window’s square should be excluded when drawing it or processing mouse input.)
It’s possible you might also be able to draw into another application’s window, but that sort of thing was generally Windows 3.1 or early X11 stuff and I don’t know if it still works on modern OSes.
I can’t say any more without knowing what language you’re asking about.