Autor Beitrag
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Mo 03.02.03 21:30 
Hallo,

ich will mehrere Bitmap-Funktionen wie z.B. GetDibColorTable() nutzen. Laut Windows-SDK brauche ich dazu einen DC und das Bitmap da rein laden. Wie mache ich das? Also einen (vom Fenster unabhängigen) DC erstellen und das Bitmap da rein laden. Oder geht das evtl. auch ohne?
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mo 03.02.03 22:34 
DC := Bitmap.Canvas.Handle

_________________
Ist Zeit wirklich Geld?
mortus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Di 04.02.03 17:53 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var
 dc,dctmp:HDC;
 bitmap:HBITMAP;
begin
     Bitmap:=LoadImage(hInstance,'c:\haha.bmp',IMAGE_BITMAP,0,0,LR_DEFAULTSIZE or LR_LOADFROMFILE);
     if bitmap=0 then exit;
     dc:=GetDC(windowhandle);
     dctmp:=CreateCompatibleDC(dc);
     SelectObject(dctmp,Bitmap);
     bitblt(dc,left,top,width,height,dctmp,0,0,SRCCOPY);
     DeleteObject(bitmap);
     DeleteDC(dctmp);
     ReleaseDC(windowhandle,dc);
end;
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Di 04.02.03 18:38 
Aber ich habe kein Fenster! Wie soll ich dann GetDc() einen Parameter übergeben? Aber trotzdem hat mich dein Beitrag auf eine Idee gebracht: ich könnte ja einfach mit CreateCompatibleDc(0) eine DC erstellen, der zum Desktop kompatibel ist, oder?
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Mi 05.02.03 10:39 
Hallo,

@Andreas Pfau

ersetze einfach
dc:=GetDC(windowhandle);

durch
dc:=GetDC(0);

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Mi 05.02.03 18:12 
Jawoll, Danke!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 05.02.03 21:16 
Ich weiß nicht, ob das so klever ist, denn jetzt hat er ein DC vom Bildschirm.
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Mi 05.02.03 21:44 
Klar, aber warum ist das unklug? Ich brauche ja nur einen DC. Ich brauche nur irgend einen X-Beliebigen DC, um GetDibColorTable() zu verwenden, warum auch immer. Oder macht das was?
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mi 05.02.03 21:45 
Andreas Pfau hat folgendes geschrieben:
Oder macht das was?

Ich denke schon, denn somit bekommst du die ColorTable des Desktops.

_________________
Ist Zeit wirklich Geld?
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Mi 05.02.03 22:06 
Oh, OK... :oops:

Was würdest du vorschlagen?
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mi 05.02.03 23:00 
siehe 1. Antwort.

_________________
Ist Zeit wirklich Geld?
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Do 06.02.03 17:42 
Äh... ich habe kein Bitmap, hur das Handle... Wie bekomme ich dann den DC?
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Do 06.02.03 18:39 
Wenn das so ist, dann verbrauchst du mit Bitmap.Handle := hbmp zu viel Speicher. Dann ist mortus' Lösung besser.

_________________
Ist Zeit wirklich Geld?
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Do 06.02.03 20:38 
Hoppla... ich habe vergessen zu sagen, dass ich auch kein Fenster habe... :oops:

Ich habe eigentlich nur eine Unit. Der wird ein HBitmap als Parameter eine Prozedur übergeben. Und da will ich halt 'ne ColorTable.

PS: Gibt es evtl. 'ne Andere Möglichkeit, also ohne DC, and die Palette zu kommen?