Can anyone tell what is wromg with this code
-
void CPixelView::OnDraw(CDC* pDC) { CPixelDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here { COLORREF color[255][255],color1[255][255]; CBitmap bitmap,bitmap1; CString file1,file2,strText; file1.Format("C:\\1.bmp"); file2.Format("C:\\3.bmp"); CDC dcMemory,dcMemory1; int r[255][255],R[255][255]; HBITMAP hBitmap1 = (HBITMAP)::LoadImage(NULL,file1,IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE );//| LR_CREATEDIBSECTION); HBITMAP hBitmap2 = (HBITMAP)::LoadImage(NULL,file2,IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE ); // Attach the loaded image to the CBitmap object. bitmap.Attach(hBitmap1); bitmap1.Attach(hBitmap2); dcMemory.CreateCompatibleDC(pDC); dcMemory.SelectObject(&bitmap); dcMemory1.CreateCompatibleDC(pDC); dcMemory1.SelectObject(&bitmap1); pDC->BitBlt(0,0,200,200,&dcMemory,0,0,SRCCOPY); pDC->BitBlt(0,0,300,700,&dcMemory1,0,0,SRCCOPY); //for all the pixels for(int i=0;i<48;i++) { for(int j=0;j<48;j++) { HDC hDC = ::GetDC(this->GetSafeHwnd()); color[i][j] = ::GetPixel(hDC,i,j); ::ReleaseDC(this->GetSafeHwnd(), hDC); r[i][j]=GetRValue(color[i][j]); HDC hDC1 = ::GetDC(this->GetSafeHwnd()); color1[i][j] = ::GetPixel(hDC1,i,j); ::ReleaseDC(this->GetSafeHwnd(), hDC1); R[i][j]=GetRValue(color1[i][j]); } }//got the pixel values } } i am inserting 2 images in this ondraw command and i want to calculate the pixel of both the pictures to compare it... can anyone tell why it is not working..complilng is done correctly but when exceute it lead to open and window with error file.. please tell asap .... thank you..
-
void CPixelView::OnDraw(CDC* pDC) { CPixelDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here { COLORREF color[255][255],color1[255][255]; CBitmap bitmap,bitmap1; CString file1,file2,strText; file1.Format("C:\\1.bmp"); file2.Format("C:\\3.bmp"); CDC dcMemory,dcMemory1; int r[255][255],R[255][255]; HBITMAP hBitmap1 = (HBITMAP)::LoadImage(NULL,file1,IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE );//| LR_CREATEDIBSECTION); HBITMAP hBitmap2 = (HBITMAP)::LoadImage(NULL,file2,IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE ); // Attach the loaded image to the CBitmap object. bitmap.Attach(hBitmap1); bitmap1.Attach(hBitmap2); dcMemory.CreateCompatibleDC(pDC); dcMemory.SelectObject(&bitmap); dcMemory1.CreateCompatibleDC(pDC); dcMemory1.SelectObject(&bitmap1); pDC->BitBlt(0,0,200,200,&dcMemory,0,0,SRCCOPY); pDC->BitBlt(0,0,300,700,&dcMemory1,0,0,SRCCOPY); //for all the pixels for(int i=0;i<48;i++) { for(int j=0;j<48;j++) { HDC hDC = ::GetDC(this->GetSafeHwnd()); color[i][j] = ::GetPixel(hDC,i,j); ::ReleaseDC(this->GetSafeHwnd(), hDC); r[i][j]=GetRValue(color[i][j]); HDC hDC1 = ::GetDC(this->GetSafeHwnd()); color1[i][j] = ::GetPixel(hDC1,i,j); ::ReleaseDC(this->GetSafeHwnd(), hDC1); R[i][j]=GetRValue(color1[i][j]); } }//got the pixel values } } i am inserting 2 images in this ondraw command and i want to calculate the pixel of both the pictures to compare it... can anyone tell why it is not working..complilng is done correctly but when exceute it lead to open and window with error file.. please tell asap .... thank you..
kaushal kishore sharma wrote:
Can anyone tell what is wromg with this code
Yes, it is badly formatted. :-D BTW: (1) Be more specific with question title. (2) Use the
code block
button to surround code snippets with<pre>
tags.kaushal kishore sharma wrote:
but when exceute it lead to open and window with error file..
(3) Report exactly what the error was.
kaushal kishore sharma wrote:
please tell asap ....
(4) urgentz questions go automatically down to the bottom of the reply stack. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
void CPixelView::OnDraw(CDC* pDC) { CPixelDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here { COLORREF color[255][255],color1[255][255]; CBitmap bitmap,bitmap1; CString file1,file2,strText; file1.Format("C:\\1.bmp"); file2.Format("C:\\3.bmp"); CDC dcMemory,dcMemory1; int r[255][255],R[255][255]; HBITMAP hBitmap1 = (HBITMAP)::LoadImage(NULL,file1,IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE );//| LR_CREATEDIBSECTION); HBITMAP hBitmap2 = (HBITMAP)::LoadImage(NULL,file2,IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE ); // Attach the loaded image to the CBitmap object. bitmap.Attach(hBitmap1); bitmap1.Attach(hBitmap2); dcMemory.CreateCompatibleDC(pDC); dcMemory.SelectObject(&bitmap); dcMemory1.CreateCompatibleDC(pDC); dcMemory1.SelectObject(&bitmap1); pDC->BitBlt(0,0,200,200,&dcMemory,0,0,SRCCOPY); pDC->BitBlt(0,0,300,700,&dcMemory1,0,0,SRCCOPY); //for all the pixels for(int i=0;i<48;i++) { for(int j=0;j<48;j++) { HDC hDC = ::GetDC(this->GetSafeHwnd()); color[i][j] = ::GetPixel(hDC,i,j); ::ReleaseDC(this->GetSafeHwnd(), hDC); r[i][j]=GetRValue(color[i][j]); HDC hDC1 = ::GetDC(this->GetSafeHwnd()); color1[i][j] = ::GetPixel(hDC1,i,j); ::ReleaseDC(this->GetSafeHwnd(), hDC1); R[i][j]=GetRValue(color1[i][j]); } }//got the pixel values } } i am inserting 2 images in this ondraw command and i want to calculate the pixel of both the pictures to compare it... can anyone tell why it is not working..complilng is done correctly but when exceute it lead to open and window with error file.. please tell asap .... thank you..