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. Put part of a gif file into imagebox?

Put part of a gif file into imagebox?

Scheduled Pinned Locked Moved C#
questiontutorial
5 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.
  • S Offline
    S Offline
    Seraphin
    wrote on last edited by
    #1

    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.

    L 1 Reply Last reply
    0
    • S Seraphin

      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.

      L Offline
      L Offline
      Lexa1983
      wrote on last edited by
      #2

      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?

      S 1 Reply Last reply
      0
      • L Lexa1983

        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?

        S Offline
        S Offline
        Seraphin
        wrote on last edited by
        #3

        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.

        L 1 Reply Last reply
        0
        • S Seraphin

          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.

          L Offline
          L Offline
          Lexa1983
          wrote on last edited by
          #4

          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); }

          S 1 Reply Last reply
          0
          • L Lexa1983

            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); }

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

            thx :)

            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