pixel writing program

Thread Starter

denison

Joined Oct 13, 2018
293
Hi everyone, Just came across this simple pixel writing program but have no idea how to use it. Apparently it uses windows GDI (graphical design interface). It would also be very laborious to use having to set colors for 256 points.
C:
#include <windows.h>

int main()
{
    HDC hdc = GetDC(GetConsoleWindow());
    for (int x = 0; x < 256; ++x)
        for (int y = 0; y < 256; ++y)
            SetPixel(hdc, x, y, RGB(127, x, y));
}
use windows GDI
Instead of using SetPixel if you used something like ReadPixel you could read the colors of a full pixel array in a digital photo for instance. Then you could edit that photo. This I presume is C++ programming. There may be a ReadPixel instruction available.
So does anybody know how I can use this program? It somehow involves using windows GDI. From there I could move onto more useful programs of reading all the pixels in a digital photo.

Mod edit: code tags - JohnInTX
 
Last edited by a moderator:

John P

Joined Oct 14, 2008
1,978
That's actually just plain old C, with the extensions that Microsoft provides for graphics under Windows. You can read instructions for it here:
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setpixel

Yes, there is a ReadPixel() function, though actually it's called GetPixel().

I use this graphics protocol, though I'm pretty clumsy with it. The details go way beyond what one person can explain to another on a forum like this! If you can find the book at this late stage of history, you might start by reading Programming Windows by Charles Petzold.

Oh, and as always: "Use code tags".
 
Last edited:

Thread Starter

denison

Joined Oct 13, 2018
293
That's actually just plain old C, with the extensions that Microsoft provides for graphics under Windows. You can read instructions for it here:
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setpixel

Yes, there is a ReadPixel() function, though actually it's called GetPixel().

I use this graphics protocol, though I'm pretty clumsy with it. The details go way beyond what one person can explain to another on a forum like this! If you can find the book at this late stage of history, you might start by reading Programming Windows by Charles Petzold.

Oh, and as always: "Use code tags".
thanks John P. I will look into your reference.
 
Top