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#
  4. split a jpg into 2 frame

split a jpg into 2 frame

Scheduled Pinned Locked Moved C#
graphicshelp
3 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
    cmarmr
    wrote on last edited by
    #1

    i am trying to split a jpg right down the center and the left fram splits ok but the right frame has the problem it is 2 time as big as it need to be and it has a huge black border to the right can somebody please help me here is my code public void split(System.Drawing.Image oimage) { System.Drawing.Bitmap bmp = new Bitmap(oimage.Width/2, oimage.Height); bmp.SetResolution(oimage.HorizontalResolution,oimage.VerticalResolution); System.Drawing.Rectangle lrec = new System.Drawing.Rectangle(0, 0,oimage.Width/2,oimage.Height); System.Drawing.Rectangle rrec = new System.Drawing.Rectangle(oimage.Width/2,0 ,oimage.Width/2, oimage.Height); System.Drawing.Image[] frames = new Image[2]; frames[0] =(Image) bmp; bmp = new Bitmap(oimage.Width, oimage.Height); bmp.SetResolution(oimage.HorizontalResolution, oimage.VerticalResolution); frames[1] =(Image) bmp; System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(frames[0]); gr.DrawImage(oimage, new Rectangle(0, 0,oimage.Width/2, oimage.Height),lrec, GraphicsUnit.Pixel); frames[0].Save(@"c:\temp\frameLeft.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); gr = System.Drawing.Graphics.FromImage(frames[1]); gr.DrawImage(oimage,new Rectangle(0, 0, oimage.Width/2, oimage.Height),rrec, GraphicsUnit.Pixel); frames[1].Save(@"c:\temp\frameRight.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); }

    Thanks, Chad Aiena

    C 1 Reply Last reply
    0
    • C cmarmr

      i am trying to split a jpg right down the center and the left fram splits ok but the right frame has the problem it is 2 time as big as it need to be and it has a huge black border to the right can somebody please help me here is my code public void split(System.Drawing.Image oimage) { System.Drawing.Bitmap bmp = new Bitmap(oimage.Width/2, oimage.Height); bmp.SetResolution(oimage.HorizontalResolution,oimage.VerticalResolution); System.Drawing.Rectangle lrec = new System.Drawing.Rectangle(0, 0,oimage.Width/2,oimage.Height); System.Drawing.Rectangle rrec = new System.Drawing.Rectangle(oimage.Width/2,0 ,oimage.Width/2, oimage.Height); System.Drawing.Image[] frames = new Image[2]; frames[0] =(Image) bmp; bmp = new Bitmap(oimage.Width, oimage.Height); bmp.SetResolution(oimage.HorizontalResolution, oimage.VerticalResolution); frames[1] =(Image) bmp; System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(frames[0]); gr.DrawImage(oimage, new Rectangle(0, 0,oimage.Width/2, oimage.Height),lrec, GraphicsUnit.Pixel); frames[0].Save(@"c:\temp\frameLeft.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); gr = System.Drawing.Graphics.FromImage(frames[1]); gr.DrawImage(oimage,new Rectangle(0, 0, oimage.Width/2, oimage.Height),rrec, GraphicsUnit.Pixel); frames[1].Save(@"c:\temp\frameRight.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); }

      Thanks, Chad Aiena

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      cmarmr wrote:

      bmp = new Bitmap(oimage.Width, oimage.Height);

      Well, it's the width of the original, because that's how you wrote it.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      C 1 Reply Last reply
      0
      • C Christian Graus

        cmarmr wrote:

        bmp = new Bitmap(oimage.Width, oimage.Height);

        Well, it's the width of the original, because that's how you wrote it.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        C Offline
        C Offline
        cmarmr
        wrote on last edited by
        #3

        thanks, minor oversight

        Thanks, Chad Aiena

        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