News:

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

Setting Pixels in Memory DC

Started by msmith, July 22, 2006, 04:55:51 AM

Previous topic - Next topic

msmith

I am currently manipulating the data of a bitmap inside a memory DC.

How can you obtain the memory address of the data so that it can be tested and set directly without GetPixel and SetPixel?

msmith

I noticed that several sites on Google say that SetPixelV is faster than SetPixel. Some say it is mush faster while other say slightly faster.

At any rate, I also noticed that most advise against this method to create transparent bitmaps because it is slow, but I like it because of the flexibility it offers (you can set individual pixels, not just transparency). Also, I have a test program with 25 controls using this method an see no perceptable delay.

I have changed to SetPixelV because even Microsoft claims it is faster.

zooba

GetBitmapBits is probably the function you're after. However, it does copy the bitmap into more memory, rather than letting you use it in place. SetBitmapBits can put it back. I haven't used these for anything performance-intensive, so I can't comment on their efficiency.

Cheers,

Zooba :U

MichaelW

#3
According to MSDN GetBitmapBits and SetBitmapBits are obsolete functions "provided only for compatibility with 16-bit versions of Windows", and should be replaced with GetDIBits and SetDIBits.  The attachment is a quick and dirty test to determine if the newer functions (Get... only) are faster. If I did everything correctly, and I'm not at all sure that I did, then the newer functions are much faster (~3.2:1 on my Windows 2000 SP4 system), despite doing more than the older functions. I started out trying to do this from a console app, but I could not make GetDIBits work with the desktop DC.

The newer cycle count macros that I used produce very repeatable results on local code that runs in less than a few thousand cycles, but I'm getting a substantial run to run variation here, I think either because I'm timing API calls, or because I'm doing it in a callback.

EDIT: Ignore this post, my test was not valid for several (stupid) reasons, and when I fix the problems GetDIBits is slower than GetBitmapBits (~10:8).



[attachment deleted by admin]
eschew obfuscation

Darrel

I use CreateDIBSection, this creates a bitmap with direct access to all the pixels.

Regards,

Darrel

msmith

GetObject does what I want.

Thanks to all for the suggestions.

Mike