Divide an image
-
How do you divide an image? Say i have a 64x64 pixel image and i want to divide this into two equal and separate triangles (triangle1 U triange2 = original image). I was thinking of using points to create regions. Since the image has four corners that i can use as four starting points, i can choose three of them to "bound" a region. Is this possible? If so could someone provide some sample code?
-
How do you divide an image? Say i have a 64x64 pixel image and i want to divide this into two equal and separate triangles (triangle1 U triange2 = original image). I was thinking of using points to create regions. Since the image has four corners that i can use as four starting points, i can choose three of them to "bound" a region. Is this possible? If so could someone provide some sample code?
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.
-
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.
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/[^]
-
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/[^]
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.
-
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.
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?
-
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?
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.
-
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.
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.
-
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.
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.
-
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.
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.
-
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.
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.
-
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.
thanks
-
thanks
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?
-
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.
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"
-
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"
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.