News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Nice basketweave window background

Started by NoCforMe, September 03, 2023, 04:37:23 PM

Previous topic - Next topic

NoCforMe

Working on my icon editor (another project that'll probably never get finished), I wanted a patterned background for the editing window so one could see the extent of the image being edited. I came up with a pretty handsome looking pattern if I don't say so myself.

Pretty simple: create a small bitmap from data in the program, use it to create a pattern brush, then just fill the window using the brush with FillRect() before displaying the image. The pattern is 2 bytes wide by 16 bytes high (16x16, 256 bits total), and it forms a tiled pattern that fills the window seamlessly.

I worked the pattern out on graph paper before coding it. It's got a few little bobbles in it, which actually make it look more ... organic. (All those NOTs are due to coding the bits that are dark, which was easier because there are fewer of them, then reversing them.)
Update: Fixed the bobbles. Now the pattern is perfect.

ImageEditBkBrushData    LABEL BYTE
    DB NOT 88h, NOT 91h
    DB NOT 44h, NOT 62h
    DB NOT 22h, NOT 26h
    DB NOT 11h, NOT 19h
    DB NOT 88h, NOT 98h
    DB NOT 44h, NOT 64h
    DB NOT 22h, NOT 46h
    DB NOT 11h, NOT 89h
    DB NOT 89h, NOT 11h
    DB NOT 46h, NOT 22h
    DB NOT 64h, NOT 44h
    DB NOT 98h, NOT 88h
    DB NOT 19h, NOT 11h
    DB NOT 26h, NOT 22h
    DB NOT 62h, NOT 44h
    DB NOT 91h, NOT 88h

$editBkBrushWidth    EQU 16
$editBkBrushHeight    EQU 16

; Create bitmap for edit window background:
    INVOKE    CreateBitmap, $editBkBrushWidth, $editBkBrushHeight, 1, 1, OFFSET ImageEditBkBrushData
    MOV    ImageEditBrushBMPhandle, EAX
; Create background brush from bitmap:
    INVOKE    CreatePatternBrush, EAX
    MOV    ImageEditBkBrush, EAX

(in WM_PAINT handler:)

; Fill window background w/pattern brush:
    INVOKE    SetTextColor, hDC, $colorEditBackground
    INVOKE    FillRect, hDC, ADDR ps.rcPaint, ImageEditBkBrush
Assembly language programming should be fun. That's why I do it.

fearless

Looks good.

There is also a PatBlt function worth looking at as well (https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-patblt)

daydreamer

Nice  :thumbsup:
I am very interested in part where you import bmp and export to tiny compressed . Ico format

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

NoCforMe

Not sure if you're replying to me or Fearless. If it's me, I didn't import anything; I created a bitmap on graph paper, then just encoded the bits as bytes in my .data section (shown in code above). Was that your question?
Assembly language programming should be fun. That's why I do it.

daydreamer

Quote from: NoCforMe on September 05, 2023, 05:49:38 AMNot sure if you're replying to me or Fearless. If it's me, I didn't import anything; I created a bitmap on graph paper, then just encoded the bits as bytes in my .data section (shown in code above). Was that your question?
You meantioned icon editor,so i expressed interested in file menu,about proc export compressed. ico file when finished editing icon
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

NoCforMe

Oh, that. I'm a looooong way away from that; still getting basic functionality working, like cropping images, etc. Lotsa work.

Regarding writing icon files, no, I'm not planning on even thinking about compression here. I don't anticipate ever working with icons large enough to require saving space.

Otherwise, writing icons is pretty easy. They're actually the same as cursor (.cur) files with the exception of one field in the file header, which I already know how to generate.
Assembly language programming should be fun. That's why I do it.