Click here to Skip to main content
15,914,074 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how can i use mfc Pin
Nelek30-Oct-07 1:47
protectorNelek30-Oct-07 1:47 
GeneralRe: how can i use mfc Pin
CodingLover30-Oct-07 19:45
CodingLover30-Oct-07 19:45 
AnswerRe: how can i use mfc Pin
ThatsAlok29-Oct-07 19:44
ThatsAlok29-Oct-07 19:44 
QuestionRe: how can i use mfc Pin
Hamid_RT29-Oct-07 20:04
Hamid_RT29-Oct-07 20:04 
QuestionRe: how can i use mfc Pin
David Crow30-Oct-07 3:39
David Crow30-Oct-07 3:39 
QuestionHow to understand CCeateContext members completely? Pin
SAMZC29-Oct-07 19:11
SAMZC29-Oct-07 19:11 
AnswerRe: How to understand CCeateContext members completely? Pin
SAMZC30-Oct-07 16:13
SAMZC30-Oct-07 16:13 
QuestionProblem with GetBitmapBits() in Win32 Pin
ashishbhatt29-Oct-07 18:49
ashishbhatt29-Oct-07 18:49 
Hi All,,

I am getting problem while getting bitmap bits from bitmap in Win32 app.And I got my bitmap data using the same thing in MFC in another app.

I used below code in Win32......
<br />
int iWidth = rect.right - rect.left;<br />
 int iHeight = rect.bottom - rect.top;<br />
<br />
 HBITMAP new_Bitmap = CreateCompatibleBitmap(m_hrootdc,iWidth,iHeight);<br />
 HBITMAP temp_Bitmap = (HBITMAP)SelectObject(m_hmemdc,new_Bitmap);<br />
<br />
<br />
// Capture screen into bitmap<br />
 BOOL blitok = BitBlt(<br />
  m_hmemdc,      rect.left - m_bmrect.left ,     <br />
  rect.top - m_bmrect.top ,<br />
  rect.right - rect.left,<br />
  rect.bottom - rect.top,<br />
  m_hrootdc,<br />
  rect.left, rect.top,<br />
  SRCCOPY);<br />
<br />
int datasize = iWidth*iHeight; <br />
COLORREF* lpClrData = (COLORREF*)LocalAlloc(LPTR, datasize * sizeof(COLORREF));<br />
datasize = GetBitmapBits(temp_Bitmap,datasize * sizeof(COLORREF), lpClrData);<br />
<br />


Here rect is the some rectangle portion,here I got datasize as some no of bytes but in lpClrData buffer I don,t get anythig.

And now I am using the same thing in MFC like bellow.....
<br />
HDC memDC = CreateCompatibleDC(m_hrootdc);<br />
CDC* pScreenDC = CDC::FromHandle(m_hrootdc);<br />
CDC* pMemDC = CDC::FromHandle(memDC);<br />
<br />
int iWidth = rect.right - rect.left;<br />
int iHeight = rect.bottom - rect.top;<br />
<br />
CBitmap newBitmap;<br />
 if (!newBitmap.CreateCompatibleBitmap(pScreenDC, iWidth,iHeight))<br />
 {<br />
  MessageBox(NULL,CString("CreateCompatibleBitmap failed."),CString("Test"),0);<br />
  return;<br />
 }<br />
<br />
CBitmap* pOldBitmap = pMemDC->SelectObject(&newBitmap);<br />
pMemDC->BitBlt(0, 0, iWidth,iHeight, pScreenDC, 0, 0, SRCCOPY);<br />
<br />
<br />
CBitmap* pbitmap = pMemDC->GetCurrentBitmap();<br />
 int datasize = iWidth*iHeight; <br />
 COLORREF* lpClrData = (COLORREF*)LocalAlloc(LPTR, datasize * sizeof(COLORREF));<br />
<br />
 datasize = pbitmap->GetBitmapBits(datasize * sizeof(COLORREF), lpClrData);<br />
<br />
<br />




Here I got the data very perfactly in buffer.

Is there something missing in my code in Win32.
Plz reply me.
I will Appreciate your answer.
Thanks in advance.



Ashish Bhatt

AnswerRe: Problem with GetBitmapBits() in Win32 Pin
Naveen29-Oct-07 18:52
Naveen29-Oct-07 18:52 
GeneralRe: Problem with GetBitmapBits() in Win32 Pin
ashishbhatt29-Oct-07 19:01
ashishbhatt29-Oct-07 19:01 
GeneralRe: Problem with GetBitmapBits() in Win32 Pin
Naveen29-Oct-07 19:15
Naveen29-Oct-07 19:15 
GeneralRe: Problem with GetBitmapBits() in Win32 Pin
ashishbhatt29-Oct-07 19:26
ashishbhatt29-Oct-07 19:26 
GeneralRe: Problem with GetBitmapBits() in Win32 Pin
ashishbhatt29-Oct-07 19:08
ashishbhatt29-Oct-07 19:08 
AnswerRe: Problem with GetBitmapBits() in Win32 Pin
Naveen29-Oct-07 20:39
Naveen29-Oct-07 20:39 
GeneralRe: Problem with GetBitmapBits() in Win32 Pin
ashishbhatt29-Oct-07 21:42
ashishbhatt29-Oct-07 21:42 
Questionhow to read an PNG file using c Pin
googlejumbo29-Oct-07 17:49
googlejumbo29-Oct-07 17:49 
AnswerRe: how to read an PNG file using c Pin
Paresh Chitte29-Oct-07 18:27
Paresh Chitte29-Oct-07 18:27 
Questionhow can i search an item in the MFCflexgrid? Pin
panthal29-Oct-07 17:37
panthal29-Oct-07 17:37 
AnswerRe: how can i search an item in the MFCflexgrid? Pin
chandu00429-Oct-07 19:44
chandu00429-Oct-07 19:44 
GeneralRe: how can i search an item in the MFCflexgrid? Pin
panthal29-Oct-07 20:13
panthal29-Oct-07 20:13 
GeneralRe: how can i search an item in the MFCflexgrid? Pin
chandu00429-Oct-07 21:39
chandu00429-Oct-07 21:39 
QuestionRe: how can i search an item in the MFCflexgrid? Pin
panthal29-Oct-07 23:07
panthal29-Oct-07 23:07 
GeneralOfftopic Pin
Nelek29-Oct-07 23:31
protectorNelek29-Oct-07 23:31 
GeneralRe: Offtopic Pin
chandu00430-Oct-07 2:26
chandu00430-Oct-07 2:26 
GeneralRe: Offtopic Pin
Nelek30-Oct-07 4:01
protectorNelek30-Oct-07 4:01 

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.