split a jpg into 2 frame
-
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
-
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
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 )
-
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 )