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. Divide an image

Divide an image

Scheduled Pinned Locked Moved C#
question
14 Posts 3 Posters 1 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 Christian Graus

    No bitmap is ever a triangle. Do you want to create bitmaps that each contain a triangle ?

    Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

    G Offline
    G Offline
    gigahertz205
    wrote on last edited by
    #3

    It doesn't necessarily have to be bitmap. I was looking into System.Drawing.Region but i have no idea because i saw a sample code that divides an image into certain size using System.Drawing.Rectangle. But i have no experience with System.Drawing. The link to the code: http://forums.msdn.microsoft.com/cs-CZ/csharpgeneral/thread/e0c30a26-60da-457d-a217-ba95650deec8/[^]

    C 1 Reply Last reply
    0
    • G gigahertz205

      It doesn't necessarily have to be bitmap. I was looking into System.Drawing.Region but i have no idea because i saw a sample code that divides an image into certain size using System.Drawing.Rectangle. But i have no experience with System.Drawing. The link to the code: http://forums.msdn.microsoft.com/cs-CZ/csharpgeneral/thread/e0c30a26-60da-457d-a217-ba95650deec8/[^]

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

      Your only other option is a byte array that cannot be displayed until you put it in a bitmap. All bitmaps are square. That's why I'm trying to clarify what you need here.

      Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

      G 1 Reply Last reply
      0
      • C Christian Graus

        Your only other option is a byte array that cannot be displayed until you put it in a bitmap. All bitmaps are square. That's why I'm trying to clarify what you need here.

        Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

        G Offline
        G Offline
        gigahertz205
        wrote on last edited by
        #5

        So then if i want to create a bitmap that contains a triangle, would I create a bitmap that can enclose the triangle and fill the rest with something like null pixel value?

        C 1 Reply Last reply
        0
        • G gigahertz205

          So then if i want to create a bitmap that contains a triangle, would I create a bitmap that can enclose the triangle and fill the rest with something like null pixel value?

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

          No such thing as null, you'd need to choose a color to fill the rest with.

          Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

          G 1 Reply Last reply
          0
          • C Christian Graus

            No such thing as null, you'd need to choose a color to fill the rest with.

            Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

            G Offline
            G Offline
            gigahertz205
            wrote on last edited by
            #7

            From what i see in System.Drawing.Region, correct me if Im wrong, I can create a region of any size and shape. System.Drawing.Rectangle uses four points to specify the size of the rectangle using four points, but i dont suppose its possible with System.Drawing.Region using three points? Im not sure if im making sense. From reading previous posts, i implied that i needed to save these two triangles separately, which meant that i need to display the divided image. However, this is not the case. I just need to divide up an image, perform some changes within those triangles and display them altogether with the changes that were made.

            C 1 Reply Last reply
            0
            • G gigahertz205

              From what i see in System.Drawing.Region, correct me if Im wrong, I can create a region of any size and shape. System.Drawing.Rectangle uses four points to specify the size of the rectangle using four points, but i dont suppose its possible with System.Drawing.Region using three points? Im not sure if im making sense. From reading previous posts, i implied that i needed to save these two triangles separately, which meant that i need to display the divided image. However, this is not the case. I just need to divide up an image, perform some changes within those triangles and display them altogether with the changes that were made.

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

              You can create a region, but that's not a bitmap. I thought a region specified an area on a bitmap, not an irregular bitmap itself. Yes, I believe the graphics object has a number of methods that take a region and only operate within that region on the bitmap. What sort of changes ?

              Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

              G 1 Reply Last reply
              0
              • C Christian Graus

                You can create a region, but that's not a bitmap. I thought a region specified an area on a bitmap, not an irregular bitmap itself. Yes, I believe the graphics object has a number of methods that take a region and only operate within that region on the bitmap. What sort of changes ?

                Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

                G Offline
                G Offline
                gigahertz205
                wrote on last edited by
                #9

                Just changing the value of the pixels. Nothing complex. So to create a region using System.Drawing.Graphics, i just use a Point array? Thanks for the responses.

                C 1 Reply Last reply
                0
                • G gigahertz205

                  Just changing the value of the pixels. Nothing complex. So to create a region using System.Drawing.Graphics, i just use a Point array? Thanks for the responses.

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

                  yeah, I believe so.

                  Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

                  G 1 Reply Last reply
                  0
                  • C Christian Graus

                    yeah, I believe so.

                    Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

                    G Offline
                    G Offline
                    gigahertz205
                    wrote on last edited by
                    #11

                    thanks

                    G 1 Reply Last reply
                    0
                    • G gigahertz205

                      thanks

                      G Offline
                      G Offline
                      gigahertz205
                      wrote on last edited by
                      #12

                      Ok few more questions: 1) How is the coordinate plane set up? Like where would the origin be? 2) could a point be outside of an image?

                      1 Reply Last reply
                      0
                      • C Christian Graus

                        No bitmap is ever a triangle. Do you want to create bitmaps that each contain a triangle ?

                        Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

                        R Offline
                        R Offline
                        Rao Rafique
                        wrote on last edited by
                        #13

                        Hey: I have understood the following problem...that u want to convert a rectangular image into two triangles... "first thing no bitmap is in the form of triangle...Because(by definition) a Bitmap is a rectangular array of pixels...so it can never be triangle" However u can read the image using byte array...with the help of Marshal.copy method....then copy Half of the array to 1st image array & half to the 2nd image array.... again use.Marshal.copy()method) to convert the bytes array to Bitmap image.... For all the above u must have concept of the following: 1-BitmapData 2-Safe & Usafe code 3-Marshal.copy()method. Th :laugh: nks

                        "Programming is a fun"

                        C 1 Reply Last reply
                        0
                        • R Rao Rafique

                          Hey: I have understood the following problem...that u want to convert a rectangular image into two triangles... "first thing no bitmap is in the form of triangle...Because(by definition) a Bitmap is a rectangular array of pixels...so it can never be triangle" However u can read the image using byte array...with the help of Marshal.copy method....then copy Half of the array to 1st image array & half to the 2nd image array.... again use.Marshal.copy()method) to convert the bytes array to Bitmap image.... For all the above u must have concept of the following: 1-BitmapData 2-Safe & Usafe code 3-Marshal.copy()method. Th :laugh: nks

                          "Programming is a fun"

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

                          Rao Rafique wrote:

                          However u can read the image using byte array...with the help of Marshal.copy method....then copy Half of the array to 1st image array & half to the 2nd image array....

                          Not a triangle, you couldn't. Not unless you copied one row at a time. And I explained that in depth, you can have the bytes in memory, but not in a format you can view.

                          Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

                          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