Put part of a gif file into imagebox?
-
I have a gif file with 3 pictures, next to next in one image. Seperated by black lines. Each picture has a width of 100pix, the black seperation line has 2 pix. Max width is 306. Now I want to copy the first picture into the imagebox. How can I copy the first picture into the imagebox? I never have worked with sprites, so I don't know how to get this.
-
I have a gif file with 3 pictures, next to next in one image. Seperated by black lines. Each picture has a width of 100pix, the black seperation line has 2 pix. Max width is 306. Now I want to copy the first picture into the imagebox. How can I copy the first picture into the imagebox? I never have worked with sprites, so I don't know how to get this.
-
It's seems that your problem is to separate one peace of entire image from other. If there is width of each peace is constant it will be very easy, but if not, you need to "search for black line"... What exactly you want to know?
-
I know exactly the positions. 1st 1-300 2nd 303-603 3rd 606-906 no dynamic problem, all pictures positions are placed logical, like sprites.
there is your code, I believe it works :)
//load needed image from file Image src = Image.FromFile(/*your image file name*/); Graphics gr = Graphics.FromImage(src); Point point = new Point(1, 0); for (int i=0; i<3; i++) { //handles the pixels of separated image Bitmap bitmap = new Bitmap(300, /*your image height*/, gr); //draw the needed part of entire image gr.DrawImageUnscaled(src, point); //make offset to next part point.Offset(303, 0); //save the destination image bitmap.Save("filename.bmp", System.Drawing.Imaging.ImageFormat.Bmp); }
-
there is your code, I believe it works :)
//load needed image from file Image src = Image.FromFile(/*your image file name*/); Graphics gr = Graphics.FromImage(src); Point point = new Point(1, 0); for (int i=0; i<3; i++) { //handles the pixels of separated image Bitmap bitmap = new Bitmap(300, /*your image height*/, gr); //draw the needed part of entire image gr.DrawImageUnscaled(src, point); //make offset to next part point.Offset(303, 0); //save the destination image bitmap.Save("filename.bmp", System.Drawing.Imaging.ImageFormat.Bmp); }