Author Topic: CreateDIBitmap  (Read 24630 times)

qWord

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: CreateDIBitmap
« Reply #45 on: June 17, 2012, 12:23:08 AM »
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

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: CreateDIBitmap
« Reply #46 on: June 22, 2012, 10:09:48 PM »
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

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: CreateDIBitmap
« Reply #47 on: August 26, 2012, 02:37:37 PM »
my first attempt at showing some swallows
needs a little work, but still exciting   :eusa_dance:


CodeDog

  • Guest
Re: CreateDIBitmap
« Reply #48 on: September 11, 2012, 12:51:38 PM »
Here is code to create a 32bpp dib section.

Code: [Select]
; ==============================================================================
; 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
« Last Edit: September 11, 2012, 05:20:13 PM by CodeDog »

CodeDog

  • Guest
Re: CreateDIBitmap
« Reply #49 on: October 06, 2012, 10:04:17 AM »
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

  • Guest
Re: CreateDIBitmap
« Reply #50 on: October 08, 2012, 03:10:22 AM »
Playing around with sine and cosine. Not very useful but funny output.