Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C++
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 26-Feb-13 13:14pm
Sergey Alexandrovich Kryukov at 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?

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 883
1 OriginalGriff 410
2 CPallini 275
3 George Jonsson 166
4 ChauhanAjay 150
0 OriginalGriff 5,450
1 CPallini 4,500
2 Sergey Alexandrovich Kryukov 4,482
3 George Jonsson 3,057
4 Gihan Liyanage 2,445

Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 26 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100