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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Convert RectanglrF To Bitmap and put this in to pictureBox

Convert RectanglrF To Bitmap and put this in to pictureBox

Scheduled Pinned Locked Moved C#
graphicstutorialhelp
6 Posts 4 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.
  • S Offline
    S Offline
    s4_sabahatf
    wrote on last edited by
    #1

    Actually we want to crop certain area from the image,so for this porpose we try this code...but now the problem is that although we got the reactangle the code is as follow!! Graphics g=this.CreateGraphics(); RectangleF Destinationrectangle=new RectangleF(530,30,100,190); RectangleF Sourcerectangle=new RectangleF(topleft,topright,bottomleft,bottomright); g.DrawImage(this.BinaryImage.Image,Destinationrectangle,Sourcerectangle,GraphicsUnit.Pixel); Now We Want to convert Destinationrectangle into Bitmap,(Is this Possible),and plz guide us how to insert this bitmap in to pictureBox Plz Reply SOON

    C J 2 Replies Last reply
    0
    • S s4_sabahatf

      Actually we want to crop certain area from the image,so for this porpose we try this code...but now the problem is that although we got the reactangle the code is as follow!! Graphics g=this.CreateGraphics(); RectangleF Destinationrectangle=new RectangleF(530,30,100,190); RectangleF Sourcerectangle=new RectangleF(topleft,topright,bottomleft,bottomright); g.DrawImage(this.BinaryImage.Image,Destinationrectangle,Sourcerectangle,GraphicsUnit.Pixel); Now We Want to convert Destinationrectangle into Bitmap,(Is this Possible),and plz guide us how to insert this bitmap in to pictureBox Plz Reply SOON

      C Offline
      C Offline
      Corinna John
      wrote on last edited by
      #2

      Why don't you draw on a bitmap? Bitmap bmp = new Bitmap(...); Graphics g = Graphics.FromImage(bmp) //... do the drawing g.Dispose();

      ____________________________________ There is no proof for this sentence.

      1 Reply Last reply
      0
      • S s4_sabahatf

        Actually we want to crop certain area from the image,so for this porpose we try this code...but now the problem is that although we got the reactangle the code is as follow!! Graphics g=this.CreateGraphics(); RectangleF Destinationrectangle=new RectangleF(530,30,100,190); RectangleF Sourcerectangle=new RectangleF(topleft,topright,bottomleft,bottomright); g.DrawImage(this.BinaryImage.Image,Destinationrectangle,Sourcerectangle,GraphicsUnit.Pixel); Now We Want to convert Destinationrectangle into Bitmap,(Is this Possible),and plz guide us how to insert this bitmap in to pictureBox Plz Reply SOON

        J Offline
        J Offline
        JoeSharp
        wrote on last edited by
        #3

        hi try this private Bitmap CreateNewBitmap(int width, int height) { Bitmap myBitmap = null; // create a new bitmap with width and height of your chooise using(Bitmap bmpNew = new Bitmap(width, height)) { using(Graphics g = Graphics.FromImage(bmpNew)) { RectangleF Destinationrectangle=new RectangleF(0,0,bmpNew.Width,bmpNew.Height); RectangleF Sourcerectangle=new RectangleF(topleft,topright,bottomleft,bottomright); g.DrawImage(this.BinaryImage.Image,Destinationrectangle,Sourcerectangle,GraphicsUnit.Pixel); } // Now create the new Bitmap myBitmap = new Bitmap(bmpNew); } return myBitmap; }

        S S 2 Replies Last reply
        0
        • J JoeSharp

          hi try this private Bitmap CreateNewBitmap(int width, int height) { Bitmap myBitmap = null; // create a new bitmap with width and height of your chooise using(Bitmap bmpNew = new Bitmap(width, height)) { using(Graphics g = Graphics.FromImage(bmpNew)) { RectangleF Destinationrectangle=new RectangleF(0,0,bmpNew.Width,bmpNew.Height); RectangleF Sourcerectangle=new RectangleF(topleft,topright,bottomleft,bottomright); g.DrawImage(this.BinaryImage.Image,Destinationrectangle,Sourcerectangle,GraphicsUnit.Pixel); } // Now create the new Bitmap myBitmap = new Bitmap(bmpNew); } return myBitmap; }

          S Offline
          S Offline
          signimage
          wrote on last edited by
          #4

          IS there is aNY Simple way through which we can convert RectangleF to Bitmap?

          1 Reply Last reply
          0
          • J JoeSharp

            hi try this private Bitmap CreateNewBitmap(int width, int height) { Bitmap myBitmap = null; // create a new bitmap with width and height of your chooise using(Bitmap bmpNew = new Bitmap(width, height)) { using(Graphics g = Graphics.FromImage(bmpNew)) { RectangleF Destinationrectangle=new RectangleF(0,0,bmpNew.Width,bmpNew.Height); RectangleF Sourcerectangle=new RectangleF(topleft,topright,bottomleft,bottomright); g.DrawImage(this.BinaryImage.Image,Destinationrectangle,Sourcerectangle,GraphicsUnit.Pixel); } // Now create the new Bitmap myBitmap = new Bitmap(bmpNew); } return myBitmap; }

            S Offline
            S Offline
            s4_sabahatf
            wrote on last edited by
            #5

            thanx for responding !! but now how will i eqiulate this bitmap into pictureBox

            J 1 Reply Last reply
            0
            • S s4_sabahatf

              thanx for responding !! but now how will i eqiulate this bitmap into pictureBox

              J Offline
              J Offline
              JoeSharp
              wrote on last edited by
              #6

              //call the function and set the bitmap the the picture box myPictureBox.Image = CreateNewBitmap(100, 100);

              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