Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Can anyone tell what is wromg with this code

Can anyone tell what is wromg with this code

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicshelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kaushal kishore sharma
    wrote on last edited by
    #1

    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..

    CPalliniC S 2 Replies Last reply
    0
    • K kaushal kishore sharma

      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..

      CPalliniC Online
      CPalliniC Online
      CPallini
      wrote on last edited by
      #2

      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]

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • K kaushal kishore sharma

        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..

        S Offline
        S Offline
        SandipG
        wrote on last edited by
        #3

        Why dont you use GetDIBits()?? BTW Please use Code block tags for posting code.

        Regards, Sandip.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups