can i create a texture line?

we can create a HPEN or HBRUSH.
but can i create a HPEN from an image?
Do you ever bother checking the internet before you ask questions here? You might find what you are looking for. Lots of information is available to those who look.

With GDI you can NOT create a pen from a texture.

From https://docs.microsoft.com/en-us/windows/win32/gdi/creating-colored-pens-and-brushes:
Although you can specify any color for a pen when creating it, the system uses only colors that are available on the device.

With GDI+ you can.

https://www.c-sharpcorner.com/uploadfile/mahesh/using-pens-in-gdi/

FYI, here's the metasearch I used to find the links:

https://duckduckgo.com/?q=WinAPI+GDI+create+a+pen+from+a+texture&t=ffsb&ia=web
And to answer the inevitable question that probably won't be asked:

Yes, it is possible to draw lines from a texture (bitmap) in DirectX. Direct3D and Direct2D.

Trying to find out how to do that is not a simple 'net search, but IMO well worth the effort. Took me about 5 minutes to find usable link resources.
At the minimum you should have checked the WinAPI documentation for GDI pen creation. There are two functions: CreatePen & CreatPenIndirect.

https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createpen
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createpenindirect
If I read correctly or ExtCreatePen() function, with LOGBRUSH::lbHatch, can do it?
"A hatch style. The meaning depends on the brush style defined by lbStyle.

If lbStyle is BS_DIBPATTERN, the lbHatch member contains a handle to a packed DIB. To obtain this handle, an application calls the GlobalAlloc function with GMEM_MOVEABLE (or LocalAlloc with LMEM_MOVEABLE) to allocate a block of memory and then fills the memory with the packed DIB. A packed DIB consists of a BITMAPINFO structure immediately followed by the array of bytes that define the pixels of the bitmap."
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-extcreatepen
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-logbrush
(sorry been late to answer, but i didn't get the notification)
Last edited on
Topic archived. No new replies allowed.