News:

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

Main Menu

Using BITMAPS to create borderless window

Started by GoneFishing, September 22, 2013, 01:36:21 AM

Previous topic - Next topic

GoneFishing

Recently I've got an idea to experiment with random numbers ...
I want to create gray scale bitmaps from arrays of 256x256 bytes each and show them as borderless windows inside parent  MDI window.
Is it possible to show custom windows in MDI ? (note - all of them will use different bitmaps )
How am I to create bitmap from array?
I've found GDICreateBitmapFromScan0 in MSDN treasury ... is it what I need for this purpose?

Just don't know how to start ...

give me a hint , please

GoneFishing

Thanks  old forum I've found something to start with:
invoke CreateBitmap, width, height, 1, 24, array


dedndave

the bitmap is easy enough
what you really want is called a "DIB Section"
DIB sections have HBITMAP handles AND you can alter the pixel data, directly

generally, i find myself creating either 256-color or 24-bit types
once in a while, you might also want to create monochrome, 16-color, or 32-bit (or a couple other types)

either way, you start off with a BITMAPINFO structure
you initialize the values in the structure, then use CreateDIBSection
the structures for 256-color and 24-bit are a little different
256-color structures contain a palette, 24-bit structures do not

give me a little time, and i will post code for 256-color and 24-bit DIB Sections

as for the "borderless windows in an MDI"
well - if you want borderless windows, maybe you don't want an MDI
MDI child windows have borders, as far as i know

but - you don't need an MDI to create a borderless child window
in fact, you may not need a child window, at all
depending on what you want to do, you might be able to just create a rectangle in the client area and use that to draw on

dedndave

question...
are you using an MDI window for other reasons
or were you thinking of using an MDI just for these windows ?

GoneFishing

#4
It makes sense what you said about MDI
All I want is to draw several different bitmaps ...
Ok, first I must learn how to create bitmaps and draw them to client area ( but in the future I want to make every of those bitmaps selectable and resizable  - that's why I mentioned MDI)
As I told all the bitmaps will be in gray scale :
R = G = B
Now I try to fill the array with random numbers:

.data
arrsize dd 256*4*256 ; bitmap 256x256 pixels , B,G,R,0 bytes for each pixel
.code
...
mov hMem,alloc(arrsize)


is it right?

GoneFishing

Quote from: dedndave on September 22, 2013, 03:22:04 AM
question...
are you using an MDI window for other reasons
or were you thinking of using an MDI just for these windows ?

just for these windows, Dave


dedndave

well - 3 things...

an MDI window is somewhat complicated - lol
although, it may be what you want, in the end - each MDI child has a border and a title bar, though
it's a little difficult to make a sizable window without borders, but it can be done

if R=G=B (i.e. all gray-shades), then 256-color bitmaps are ideal

you may not need to allocate memory for the array
just use the DIB Section data area as the array   :biggrin:

GoneFishing

#7
Quote from: dedndave on September 22, 2013, 03:33:48 AM
if R=G=B (i.e. all gray-shades), then 256-color bitmaps are ideal

you may not need to allocate memory for the array
just use the DIB Section data area as the array   :biggrin:

Ok, let's forget about MDI for now  :biggrin:
I will make it simple
So CreateDIBSection function is what I must call firstly to get an offset to bitmap bits ... am I right?

dedndave

right
you pass it the address of a BITMAPINFO structure and the address of a dword that will receive a pointer to the data

jj2007

Quote from: vertograd on September 22, 2013, 01:36:21 AM
Is it possible to show custom windows in MDI ? (note - all of them will use different bitmaps )

Maybe?
\Masm32\examples\exampl01\mdidemo\mditest.asm
MakeMDIwin proc
..
    mov mdihWnd, eax
    invoke SetWindowLong, eax, GWL_STYLE, WS_CHILD or WS_THICKFRAME
    invoke ShowWindow,mdihWnd,SW_SHOW
    invoke MoveWindow, mdihWnd, 9, 9, 300, 200, 1
    ret

GoneFishing

Quote from: jj2007 on September 22, 2013, 03:58:35 AM
Quote from: vertograd on September 22, 2013, 01:36:21 AM
Is it possible to show custom windows in MDI ? (note - all of them will use different bitmaps )

Maybe?
\Masm32\examples\exampl01\mdidemo\mditest.asm
MakeMDIwin proc
..
    mov mdihWnd, eax
    invoke SetWindowLong, eax, GWL_STYLE, WS_CHILD or WS_THICKFRAME
    invoke ShowWindow,mdihWnd,SW_SHOW
    invoke MoveWindow, mdihWnd, 9, 9, 300, 200, 1
    ret


JOCHEN
It works!!!  :t
Though the windows seem to be semi-transparent . I can't figure out is it intentionally or not  :redface:

GoneFishing

  FINDSTR /S "BITMAPINFO" *.ASM in  \MASM32\EXAMPLES folder  gave me two excellent results:
  • exampl01\showdib\showdib2.asm:
  • exampl04\pascal\pascal.asm:
+ examples\exampl01\mdidemo\mditest.asm
Now I have all required info

Thank you, Dave and Jochen !

dedndave

#12
try this out....

notice that rows in bitmaps are inverted
that is, the bottom row of the image is the first row of data
you can invert this behaviour by negating the image height in the header
however, inverted bitmaps cannot be compressed (not within the ms bitmap RLL spec, at least)
this is part of the very old windows bitmap specification, dating back to before windows 3   :P

seeing as we are filling the bitmap with random data, it doesn't matter

GoneFishing

WOW , Dave
It's wonderful!!!  :t
Those pictures remind me wet sand textures !
Thank you SO MUCH !

dedndave

i had fun writing it   :t

and - when i first got it up and running, i saw a flaw in my random generator code
a good random generator should create nice "blended" bitmaps
mine had a streak in it of darker columns   :redface:
now fixed, and generating better random data   :t