Click here to Skip to main content
15,902,909 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: GDI Object leak detection Pin
John R. Shaw8-Aug-05 19:39
John R. Shaw8-Aug-05 19:39 
Generalmr MFC please do something when I press a key Pin
Spiritofamerica8-Aug-05 10:29
Spiritofamerica8-Aug-05 10:29 
GeneralRe: mr MFC please do something when I press a key Pin
Stober8-Aug-05 11:02
Stober8-Aug-05 11:02 
GeneralRe: mr MFC please do something when I press a key Pin
Michael Kane9-Aug-05 4:48
Michael Kane9-Aug-05 4:48 
GeneralRe: mr MFC please do something when I press a key Pin
Spiritofamerica13-Aug-05 9:46
Spiritofamerica13-Aug-05 9:46 
GeneralRe: mr MFC please do something when I press a key Pin
Rick York8-Aug-05 11:44
mveRick York8-Aug-05 11:44 
GeneralRe: mr MFC please do something when I press a key Pin
Spiritofamerica13-Aug-05 9:49
Spiritofamerica13-Aug-05 9:49 
GeneralDrawing Text into a Bitmap with GDI Pin
wookie1828-Aug-05 8:56
wookie1828-Aug-05 8:56 
Hello,

I want to draw some text into a bitmap image. The image is stored in the memory. I just want to place some text in there. Afterwards it should be processed by a DirectShow pipeline but this doesn't matter here....

I tried a lot with GDI, but it doesn't work so far. Here is my code:


unsigned __int8 pBuffer; //pointer to image data<br />
int m_ImageWidth = 1024; //dimensions of the image<br />
int m_ImageHeight = 1024;<br />
<br />
BITMAP bmp = {0,m_ImageWidth,m_ImageHeight,m_ImageWidth,1,8,pBuffer};<br />
HBITMAP hBMP = CreateBitmapIndirect(&bmp);<br />
HDC hDC_bmp = CreateCompatibleDC(0);<br />
HBITMAP hBMPc = CreateCompatibleBitmap(hDC_bmp,m_ImageWidth,m_ImageHeight);<br />
HGDIOBJ x =	SelectObject(hDC_bmp, hBMPc);<br />
<br />
<br />
<br />
HDC hDC_txt = CreateCompatibleDC(0);<br />
int b = BitBlt(hDC_bmp,0,0,200,200,hDC_txt,0,0,BLACKNESS);<br />
<br />
char text_tag[16];<br />
sprintf(text_tag,"0123456789");<br />
RECT rect = {0,0,200,200};<br />
	<br />
int a = DrawText(hDC_txt,TEXT(text_tag),1,&rect,DT_LEFT);<br />
<br />
BITMAPINFO bmInfo;<br />
memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));<br />
bmInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);<br />
bmInfo.bmiHeader.biWidth=m_ImageWidth;<br />
bmInfo.bmiHeader.biHeight=m_ImageHeight;<br />
bmInfo.bmiHeader.biPlanes=1;<br />
bmInfo.bmiHeader.biBitCount=24;<br />
	<br />
HBITMAP g = CreateDIBitmap(hDC_txt,&bmInfo.bmiHeader,0,0,0,DIB_RGB_COLORS);<br />
<br />
int c = GetObject(g,1024*1024,(void*)pBuffer);


After processing these lines i think I should have the image with the text in the Buffer "pBuffer". But I don't have. Can anyone tell me why and how it works??? I am also open to a different method which just puts text into my bitmap.

Thanks for help
chris
GeneralRe: Drawing Text into a Bitmap with GDI Pin
Chris Losinger8-Aug-05 10:07
professionalChris Losinger8-Aug-05 10:07 
GeneralRe: Drawing Text into a Bitmap with GDI Pin
wookie1828-Aug-05 10:27
wookie1828-Aug-05 10:27 
GeneralRe: Drawing Text into a Bitmap with GDI Pin
John R. Shaw8-Aug-05 20:02
John R. Shaw8-Aug-05 20:02 
GeneralRe: Drawing Text into a Bitmap with GDI Pin
Anonymous9-Aug-05 2:44
Anonymous9-Aug-05 2:44 
GeneralRe: Drawing Text into a Bitmap with GDI Pin
John R. Shaw9-Aug-05 9:48
John R. Shaw9-Aug-05 9:48 
GeneralShow bitmap on Button Pin
Aditya Rao8-Aug-05 8:31
Aditya Rao8-Aug-05 8:31 
GeneralRe: Show bitmap on Button Pin
David Crow8-Aug-05 9:29
David Crow8-Aug-05 9:29 
GeneralRe: Show bitmap on Button Pin
Ravi Bhavnani8-Aug-05 9:47
professionalRavi Bhavnani8-Aug-05 9:47 
GeneralRe: Show bitmap on Button Pin
ThatsAlok8-Aug-05 18:32
ThatsAlok8-Aug-05 18:32 
GeneralWM_PAINT wackienss Pin
Peter Weyzen8-Aug-05 8:19
Peter Weyzen8-Aug-05 8:19 
GeneralRe: WM_PAINT wackienss Pin
Jose Lamas Rios8-Aug-05 8:24
Jose Lamas Rios8-Aug-05 8:24 
GeneralRe: WM_PAINT wackienss Pin
Peter Weyzen8-Aug-05 8:31
Peter Weyzen8-Aug-05 8:31 
Generaldetecting a window in win32 Pin
celllllllll8-Aug-05 6:17
celllllllll8-Aug-05 6:17 
GeneralRe: detecting a window in win32 Pin
BlackDice8-Aug-05 6:26
BlackDice8-Aug-05 6:26 
GeneralRe: detecting a window in win32 Pin
celllllllll8-Aug-05 7:13
celllllllll8-Aug-05 7:13 
GeneralRe: detecting a window in win32 Pin
David Crow8-Aug-05 8:07
David Crow8-Aug-05 8:07 
GeneralRe: detecting a window in win32 Pin
celllllllll8-Aug-05 11:29
celllllllll8-Aug-05 11:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.