Click here to Skip to main content
15,892,797 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need help coding a fast screen display for a Windows Mandelbrot-set program . I am presently setting pixel colors one-at-a-time with SetPixel(x,y,RGB(r.g.b)). This function is notoriously slow and consumes all the time expended on generate the Mandelbrot set display. (2.2 sec at this point) I want to use no more than 20 msec so I can do some real-time computer graphics operations on the Mandelbrot object. (rotate, scroll, flip, etc.) I haven’t done any programming for 10+ years and am more than a little rusty. I assume that 20 msec is achievable with today’s display adapters and the right programming.

Is this correct?

I understand that screen displays can be generated at reasonable speed if I construct a bitmap from the pixel values. I’m pretty confident of my ability to handle the transfer from a bitmap to the screen but I haven’t doped out how to create an empty bitmap with enough storage capacity for a map of the whole screen (multi megabytes for any kind of modern color display) The functions I have looked at rely on a pointer to an array of the pixel data. If I must arrange for that much storage space, the heap is the only place that makes sense. A global array would make a massive .EXE file; a local array would overwhelm the stack.

If I use heap memory, how do I do it for screen sizes known only at run time?

Some write-ups imply that the BITMAP functions themselves reserve the space in the heap.

Is this true?

That would be simplify things for me. Actually My preference would be to continue to write the color data to the screen, one pixel at the time. Sort of a one pixel transfer at a time via bitblt to the display adapter . Would that run faster than SetPixel? I understand that SetPixel is slow because the display adapter has to match its colors up with the RGB color specified in SetPixel. Would a single pixel bitblt have the same limitation?

But I may be completely at sea on this. I would appreciate any help. I want understand what I’m doing, not simply copy someone else’s code. That would defeat my basic purpose of keeping my mind reasonably sharp.
Posted
Comments
Sergey Alexandrovich Kryukov 26-Feb-13 19:22pm    
What exactly you are using? GDI+? SetPixel is simply unacceptable. The real solution (and you case is very simple, you only write pixels) is to set all bits in memory and then write it all to Bitmap at once. You will find many places with demo solution. Another fast alternative is DirectX... This is not really a serious problem, you will certainly do it faster then you calculate out Mandelbrot set fragment. Come on, load a JPEG file and show on screen: isn't it very fast?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900