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. Resize bitmap from Clipborad?

Resize bitmap from Clipborad?

Scheduled Pinned Locked Moved C / C++ / MFC
graphicstutorialquestion
5 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.
  • J Offline
    J Offline
    JoneLe86
    wrote on last edited by
    #1

    What I am up to is resizing the bitmap from the clipboard then re send it to clipborad so it's kinda easy in VB take a look

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    My.Computer.Clipboard.SetImage(New Bitmap(bmp, CInt(bmp.Width / 2), CInt(bmp.Height / 2))) ' resized and pasted to Excel
    End Sub

    No how to do this under C? So i can send the bitmap to the clipboard with these instructions

    OpenClipboard(NULL);
    EmptyClipboard();
    SetClipboardData(CF_BITMAP, Hbitmap);
    CloseClipboard();
    OpenClipboard(NULL);

    and for bringing it

    HBITMAP hbitmap = (HBITMAP)getclipboardData(CF_BITMAP)

    and i know that I should use

    StretchBlt()

    but i do not know how to accomplice that?

    T J 2 Replies Last reply
    0
    • J JoneLe86

      What I am up to is resizing the bitmap from the clipboard then re send it to clipborad so it's kinda easy in VB take a look

      Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
      My.Computer.Clipboard.SetImage(New Bitmap(bmp, CInt(bmp.Width / 2), CInt(bmp.Height / 2))) ' resized and pasted to Excel
      End Sub

      No how to do this under C? So i can send the bitmap to the clipboard with these instructions

      OpenClipboard(NULL);
      EmptyClipboard();
      SetClipboardData(CF_BITMAP, Hbitmap);
      CloseClipboard();
      OpenClipboard(NULL);

      and for bringing it

      HBITMAP hbitmap = (HBITMAP)getclipboardData(CF_BITMAP)

      and i know that I should use

      StretchBlt()

      but i do not know how to accomplice that?

      T Offline
      T Offline
      thanh_bkhn
      wrote on last edited by
      #2

      Assume you have a HBITMAP hbitmap which already contains your clipboard data. Then you can StretchBlt that data to a destination HDC hdc as below: 1. Create a compatible HDC in memory with your destination hdc

      HDC memDC= CreateCompatibleDC(hdc);

      2. Select your hbitmap into the memory DC

      HBITMAP hOldBmp = (HBITMAP)SelectObject(memDC, hbitmap);

      3. Use StretchBlt to resize it

      StretchBlt(hdc, 0, 0, new_Width, new_Height, memDC, 0, 0, org_Width, org_Height, SRCCOPY);

      4. Restore the old bitmap and free memory

      SelectObject(memDC, hOldBmp);
      DeleteDC(memDC);

      Hope it helps :)

      J 1 Reply Last reply
      0
      • J JoneLe86

        What I am up to is resizing the bitmap from the clipboard then re send it to clipborad so it's kinda easy in VB take a look

        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        My.Computer.Clipboard.SetImage(New Bitmap(bmp, CInt(bmp.Width / 2), CInt(bmp.Height / 2))) ' resized and pasted to Excel
        End Sub

        No how to do this under C? So i can send the bitmap to the clipboard with these instructions

        OpenClipboard(NULL);
        EmptyClipboard();
        SetClipboardData(CF_BITMAP, Hbitmap);
        CloseClipboard();
        OpenClipboard(NULL);

        and for bringing it

        HBITMAP hbitmap = (HBITMAP)getclipboardData(CF_BITMAP)

        and i know that I should use

        StretchBlt()

        but i do not know how to accomplice that?

        J Offline
        J Offline
        Jochen Arndt
        wrote on last edited by
        #3

        You may use the CopyImage()[^] function:

        BITMAP bm;
        GetObject(hBitmap, sizeof(bm), &bm);
        HBITMAP hCopy = (HBITMAP)CopyImage(hBitmap, IMAGE_BITMAP,
        bm.bmWidth / 2, bm.bmHeight / 2,
        LR_COPYDELETEORG);
        SetClipboardData(CF_BITMAP, hCopy);

        J 1 Reply Last reply
        0
        • T thanh_bkhn

          Assume you have a HBITMAP hbitmap which already contains your clipboard data. Then you can StretchBlt that data to a destination HDC hdc as below: 1. Create a compatible HDC in memory with your destination hdc

          HDC memDC= CreateCompatibleDC(hdc);

          2. Select your hbitmap into the memory DC

          HBITMAP hOldBmp = (HBITMAP)SelectObject(memDC, hbitmap);

          3. Use StretchBlt to resize it

          StretchBlt(hdc, 0, 0, new_Width, new_Height, memDC, 0, 0, org_Width, org_Height, SRCCOPY);

          4. Restore the old bitmap and free memory

          SelectObject(memDC, hOldBmp);
          DeleteDC(memDC);

          Hope it helps :)

          J Offline
          J Offline
          JoneLe86
          wrote on last edited by
          #4

          Thanks it helped me :)

          1 Reply Last reply
          0
          • J Jochen Arndt

            You may use the CopyImage()[^] function:

            BITMAP bm;
            GetObject(hBitmap, sizeof(bm), &bm);
            HBITMAP hCopy = (HBITMAP)CopyImage(hBitmap, IMAGE_BITMAP,
            bm.bmWidth / 2, bm.bmHeight / 2,
            LR_COPYDELETEORG);
            SetClipboardData(CF_BITMAP, hCopy);

            J Offline
            J Offline
            JoneLe86
            wrote on last edited by
            #5

            Thanks I did not know that! :-D gonna check that out

            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