Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (WinAPI, Konsole) » Pixel

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: > 1 <
000
25.09.2006, 17:44 Uhr
-Biohazard-



Hallo Programmierer,
wie kann ich in WinAPI die Pixel einer bestimmten Koordinate ein Farbe zuweisen? Also dass Koordinate x=100 und y=100 230 rote Farbeanteile, 0 grüne Farbanteile und 0 blaue Farbanteile hat.

MfG
-Biohazard-
--

Dieser Post wurde am 25.09.2006 um 18:14 Uhr von -Biohazard- editiert.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
001
25.09.2006, 18:41 Uhr
xXx
Devil


meinst du SetPixel ?
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
002
25.09.2006, 21:12 Uhr
-Biohazard-



Hallo xXx,
danke für deine Antwort. Ich kann mit folgendem Code prima die Konsole anmalen.

Code:
#include <windows.h>
#include <iostream.h>
#include <conio.h>
using namespace std;

int main()
{
  short variablenname;
  int x, y;
  POINT koord;
  HWND fgr = GetConsoleWindow();
  HDC fgr1 = GetDC( fgr );
  while ( 1 )
  {
    GetCursorPos( & koord );
    x = koord.x;
    y = koord.y;
    SetPixel( fgr1, x, y, RGB( rand() % 255, rand() % 255, rand() % 255 ) );
}
}

Jedoch würde ich das auch gerne mit dem ganzen Bildschirm machen. Welches Handle muss man dann aufrufen?
Danke für deine Antwort
--
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
003
25.09.2006, 21:21 Uhr
xXx
Devil


Hmm evt. ClientToScreen nehmen ... aber normal nicht
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
004
25.09.2006, 21:47 Uhr
-Biohazard-



Danke nochmals xXx,
aber wie es scheint fand ich leider über Googlesuche nichts.
Trotzdem danke

-Biohazard-
--
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
005
26.09.2006, 14:32 Uhr
Tommix



Hallo,
GetDesktopWindow()

Gruß, Tommix
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
006
26.09.2006, 16:54 Uhr
xXx
Devil


oh ja das hab ich nat. übersehen ... hmm wie Tommix schon sagte muss du dir das HWND des Desktops holen ... weil du dir im moment nur das HWND der Console holst ... und davon dann den Device Context ...


C++:
#include <windows.h>
// #include <iostream> // Wo nutzt du denn ne func daraus? :D
// #include <conio.h> // Wo nutzt du ne func hierraus? ;)

int main()
{
    POINT ptCursor;
    HWND hWndDesktop  = GetDesktopWindow();
    HDC   hDC               = GetDC(hWndDesktop);
  
    // srand() ?? Fehlt wohl auch ...
    while (true)
    {
        GetCursorPos(&ptCursor);
        SetPixel(hDC, ptCursor.x, ptCursor.y, RGB(rand()%255, rand()%255, rand()%255));
    }
}
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
007
27.09.2006, 22:31 Uhr
~B0nze
Gast



Code:
ReleaseDC( hWndDesktop, hDC );



nicht vergessen
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
008
28.09.2006, 14:18 Uhr
xXx
Devil


Hmm ... ne würde eh nie aufgerufen man muss sich halt ne abbruch bedingung reinbauen ... dann wöre nen releasedc angebracht
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: > 1 <     [ C / C++ (WinAPI, Konsole) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: