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. About realize the function of selecting discretioal image

About realize the function of selecting discretioal image

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestion
7 Posts 2 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.
  • C Offline
    C Offline
    Chen XuNuo
    wrote on last edited by
    #1

    In Windows' Drawing Tool,there is a funtion that is we can select the discretioal part of the image.How can it realize? Have I make a clear expression?;P I appreciate your hint.

    H 1 Reply Last reply
    0
    • C Chen XuNuo

      In Windows' Drawing Tool,there is a funtion that is we can select the discretioal part of the image.How can it realize? Have I make a clear expression?;P I appreciate your hint.

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Do you want to select sections of an image and cut or other actions on the it?


      WhiteSky


      C 1 Reply Last reply
      0
      • H Hamid Taebi

        Do you want to select sections of an image and cut or other actions on the it?


        WhiteSky


        C Offline
        C Offline
        Chen XuNuo
        wrote on last edited by
        #3

        Yes,I want to cut the section I select from the image.

        H 1 Reply Last reply
        0
        • C Chen XuNuo

          Yes,I want to cut the section I select from the image.

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Check this code:

          BOOL CDialogDlg::OnInitDialog()
          {
          m_Image.Load("c:\\123.jpg");
          }

          void CDialogDlg::OnPaint()
          {
          CPaintDC dc(this);
          m_Image.BitBlt(dc.m_hDC,0,0,800,600,0,0);
          CDialog::OnPaint();
          }

          void CDialogDlg::OnBnClickedOk()
          {
          int x,y;
          x=200;
          y=200;
          HDC dc;
          HBITMAP hbit;
          dc=CreateCompatibleDC(GetDC()->m_hDC);
          hbit=CreateCompatibleBitmap(GetDC()->m_hDC,x,y);
          SelectObject(dc,hbit);
          BitBlt(dc,0,0,x,y,GetDC()->m_hDC,100,100,SRCCOPY);

          //output in the file
          CImage m_Image33;
          m_Image33.Attach(hbit);
          m_Image33.Save("d:\\22.bmp");
          m_Image33.Detach();
          DeleteDC(dc);
          DeleteObject(hbit);
          }


          WhiteSky


          C 1 Reply Last reply
          0
          • H Hamid Taebi

            Check this code:

            BOOL CDialogDlg::OnInitDialog()
            {
            m_Image.Load("c:\\123.jpg");
            }

            void CDialogDlg::OnPaint()
            {
            CPaintDC dc(this);
            m_Image.BitBlt(dc.m_hDC,0,0,800,600,0,0);
            CDialog::OnPaint();
            }

            void CDialogDlg::OnBnClickedOk()
            {
            int x,y;
            x=200;
            y=200;
            HDC dc;
            HBITMAP hbit;
            dc=CreateCompatibleDC(GetDC()->m_hDC);
            hbit=CreateCompatibleBitmap(GetDC()->m_hDC,x,y);
            SelectObject(dc,hbit);
            BitBlt(dc,0,0,x,y,GetDC()->m_hDC,100,100,SRCCOPY);

            //output in the file
            CImage m_Image33;
            m_Image33.Attach(hbit);
            m_Image33.Save("d:\\22.bmp");
            m_Image33.Detach();
            DeleteDC(dc);
            DeleteObject(hbit);
            }


            WhiteSky


            C Offline
            C Offline
            Chen XuNuo
            wrote on last edited by
            #5

            But the section was selected by the mouse,so the section is not a rect.

            H 1 Reply Last reply
            0
            • C Chen XuNuo

              But the section was selected by the mouse,so the section is not a rect.

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              You want to select an area with mouse ok,its easy you have a click when you click mouse you must save start position with CPoint point;GetCursorPos(&point); that is x and y and when you free mouse its height,width thus you can select an area.


              WhiteSky


              C 1 Reply Last reply
              0
              • H Hamid Taebi

                You want to select an area with mouse ok,its easy you have a click when you click mouse you must save start position with CPoint point;GetCursorPos(&point); that is x and y and when you free mouse its height,width thus you can select an area.


                WhiteSky


                C Offline
                C Offline
                Chen XuNuo
                wrote on last edited by
                #7

                But the area is not a regular one... X|

                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