How to change a pixel color with out using SetPixel() function

Posted on 2008-11-10
Last Modified: 2013-12-14
        How can I change the Pixel color of our window DC with out using the function SetPixel() function
in Vc++, I am searching for a method for getting the direct pointer address of our window DC location.
So I can change the RGB value using memory address (Pointer)
Question by:inampudi1
    LVL 30

    Accepted Solution

    Hi inampudi,

    IMO direct access to pixel's RGB values of a window's DC is not possible. For example see this discussion:

    You can create a memory device context (CreateCompatibleDC). For this you can create DIB (i.e. CreateDIBSection) and access the pixels there - then use BitBlt to draw this bitmap to the window ...

    Hope that helps,



    Author Comment

    Hi experts,
                          can We create a DIB which will automatically refresh to the DC with out calling BitBlt or StretchBlt etc like functions . Because i want a very fast method. Is BitBlt() copy the entire image to the DC or Just set The pointer.Or is there any method to directly set out DIB pointer to our Window DC.
    LVL 30

    Expert Comment

    Hi again,

    no, IMO you can't do anything else than blitting the bitmap to the real DC (at least not in Windows GDI) - the problem simply is you would need to have access to the graphics-card's memory which is blocked - the only way to achive such things would be to use DirectX/DirectDraw. Anyway, how fast do you want to have it? BitBlt isn't such slow - for example I once wrote a bitmap roation test program which managed to rotate and paint a 800x600 pixel image on a 2,4 GHz machine with about 160 fps.

    BitBlt copies the image (or a part of it) to the real DC ...


    Author Closing Comment

    HI Zoppo,
                         Your Guidance is Good, it is well cleared..
    And it is very helpfull to me...
    LVL 30

    Expert Comment

    That's fine, I'm glad I could help ...

    Have a nice day,

    best regards,


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
    Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now