News:

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

Main Menu

CreateDIBitmap

Started by masitecno, May 31, 2012, 12:47:34 PM

Previous topic - Next topic

qWord

Hi masitecno,

Your animation technique not correct: you are implementing a delay while handling the WM_PAINT message. This means that the window can process any message until the animation is finished. A better method is to use a timer (SetTimer) and draw to a memory DC while handling the WM_TIMER-message. This DC is copied to the screen while handling WM_PAINT.
For manipulating the bits, I would use GDI+, because its interface is IMO much simpler for that purpose...

regards, qWord
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

here is something to get us started
probably several ways to improve it   :P

i just took my MDI template, and added a few routines

dedndave

my first attempt at showing some swallows
needs a little work, but still exciting   :eusa_dance:


CodeDog

#48
Here is code to create a 32bpp dib section.

; ==============================================================================
; Creates a 32bpp DIB section, returns 0 on failure, otherwise eax contains handle of dib
; and the variable pointed to by ppvBits will point to the bits data of the DIB section.
; dc should be returned by GetDC so that it can create a compatible DIB section..
; Use SelectObject to select handle of dib into a dc when you need to use it
; Use ppvBits to operate on the bits data.
; Use DeleteObject and the handle of the dib to free it when done
; Remember to select the old object into the dc too when done.
; if w and h are null, it will use the current screen dimensions
ALIGN 16
NewDib32 PROC dc:HDC, ppvBits:PTR DWORD, w:DWORD, h:DWORD
LOCAL bminfo:BITMAPINFO

; Fill in bitmapinfo
xor edx, edx
mov eax, w
mov ecx, h
mov bminfo.bmiHeader.biSize, SIZEOF BITMAPINFOHEADER
mov bminfo.bmiHeader.biPlanes, 1
mov bminfo.bmiHeader.biBitCount, 32
mov bminfo.bmiHeader.biCompression, BI_RGB
neg ecx ; create top down dib, not bottom up (make height signed)
mov bminfo.bmiHeader.biSizeImage, edx
mov bminfo.bmiHeader.biXPelsPerMeter, edx
mov bminfo.bmiHeader.biYPelsPerMeter, edx
mov bminfo.bmiHeader.biClrUsed, edx
mov bminfo.bmiHeader.biClrImportant, edx
.IF eax==0 && ecx==0
INVOKE GetSystemMetrics, SM_CYSCREEN
neg eax
push eax
INVOKE GetSystemMetrics, SM_CXSCREEN
pop ecx
.ENDIF
mov bminfo.bmiHeader.biWidth, eax
mov bminfo.bmiHeader.biHeight, ecx
INVOKE CreateDIBSection, dc, ADDR bminfo, DIB_RGB_COLORS, ppvBits, NULL, 0
ret
NewDib32 ENDP


CodeDog

Quote from: dedndave on August 26, 2012, 02:37:37 PM
my first attempt at showing some swallows
needs a little work, but still exciting   :eusa_dance:

Here is a fire demo i've made using dib sections.  :eusa_dance:




CodeDog

Playing around with sine and cosine. Not very useful but funny output.