CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 1999
    Posts
    98

    SetPixel too slow!!

    How do i get a pointer to the display buffer in windows, so i can do memset operations on it and such?
    Last edited by nouser; April 18th, 2009 at 10:15 PM.

  2. #2
    Join Date
    Apr 1999
    Posts
    396

    Re: SetPixel too slow!!

    DirectDraw


  3. #3
    Join Date
    Jul 1999
    Posts
    98

    Re: SetPixel too slow!!

    Wow, you are just so much help! I don't know what'd I'd have done without you.
    Last edited by nouser; April 18th, 2009 at 10:15 PM.

  4. #4
    Join Date
    Jun 2001
    Location
    Lewes, UK
    Posts
    1,313

    Re: SetPixel too slow!!

    Todd gave you the correct answer to your question. You can't just grab a look the the video memory and monkey around with it in Windows. You either go through the GDI API or use the DirectDraw API which is closer to the metal.

    Hope this helps

    Eugene Gill

    Please take the time to rate this answer if you found it useful. It will make me a happy man!

  5. #5
    Join Date
    Jun 2001
    Location
    Lewes, UK
    Posts
    1,313

    Re: SetPixel too slow!!

    Or OpenGL.

    Hope this helps

    Eugene Gill

    Please take the time to rate this answer if you found it useful. It will make me a happy man!

  6. #6
    Join Date
    Oct 2000
    Location
    Tehran - Iran
    Posts
    949

    Re: SetPixel too slow!!

    Hi, use of DirectDraw ...
    I read article that was about 15 ways to set pixel in monitor in DirectDraw, it was nice ...
    You can buy and read Andre LaMonthe books

    My month article: Game programming by DirectX by Lan Mader.
    Please visit in: www.geocities.com/hadi_rezaie/index.html

    Hadi Rezaie

  7. #7
    Join Date
    Mar 2001
    Location
    Singapore
    Posts
    57

    Re: SetPixel too slow!!

    if you just want to access the bytes of the image, say change the red channels of certain
    pixels at certain location (watever), why dont you try DIB.
    You should be able to find the example DIBLOOK in MSDN.

    lorba



  8. #8
    Join Date
    Apr 2001
    Posts
    50

    Re: SetPixel too slow!!

    Here is how you do it:



    int i=4 * bmi.bmiHeader.biWidth * bmi.bmiHeader.biHeight;

    /* allocate your buffer here with something like
    long *buffer = new long[i/4]; */

    int iRet = GetDIBits(hDC,hBitmap,0,bitmap.bmHeight,(char *)buffer,&bmi,DIB_RGB_COLORS); // This sets the Dev Indep bits




    This assumes that you are starting with a bitmap compatible with your HDC and that you want 32-bit pixels to work with in your buffer. (They are the easiest.)

    Then of course you do whatever you want with the buffer, and call SetDIBits to set them again all at once. It will automatically do the conversion back to screen/device color depth.

    Good luck.


    Giving rating points to good posts is sexy...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured