News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GDI Brushes, Pens, Bitmaps

Started by zemtex, January 27, 2011, 01:08:59 AM

Previous topic - Next topic

zemtex

Hi.

I have created a GDI object of type HBITMAP. I paint some graphics into it and then I create a pattern brush from it by calling CreatePatternBrush. I store the brush in a global variable to avvoid losing it when I need it in WM_PAINT. I create the bitmap and the brush in the WM_INITDIALOG

My question is, can I delete the bitmap after creating the brush or is the brush dependant on the bitmap, is the brush just a pointer to the bitmap or is the brush standing on its own after its created?
The hopeless windows docs says nothing about this.
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

hutch--

Have a look at the API functions SelectObject() and DeleteObject(). An allocated brush is a different animal but remember when you use SelectObject() that you save the old object and when you are finished you reselect the old object and delete your new one.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zemtex

When I draw a bitmap at the bottom of my screen, about 60% of the bottom of the bitmap ends up in the upper region and the other 40% gets wrapped beneath that again. Why does this not happen when i print the same bitmap at the very top of the DC bitmap?

I have checked coordinates, they should be alright, and not crossing any borders.

Here is an illustration of what I mean:

I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

zemtex

I Solved it. SetBrushOrgEx should be used to properly align.
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

zemtex

#4
Btw, why doesnt my StretchBlt mirror my image, I want it mirrored on the vertical axis.

This doesnt work, it produces blackness and the bitmap disappears.

      invoke StretchBlt, memDC2, 0, 0, rect.right, 82, memDC, 0, 0, rect.right, -82, SRCCOPY


Fixed it:

      invoke StretchBlt, memDC2, 0, 0, rect.right, 82, memDC, 0, 82, rect.right, -82, SRCCOPY


Btw (again): The bitmap above looks untasteful and waste of bytes, but trust me its not what it looks like, its a very humble and resource friendly thing. Just so that people dont think im one of those kiddies who put all kinds of bitmaps in their window just-to-look-cool-sort of thing. Its a totally different thing.
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.