Change values of pixels in an area?
-
How would i go about changing values in pixels in an area? Note, all pixels will have the same value. I was thinking of using unsafe code to visit every single pixel in that area, but that may be too slow if i do this multiple time.
-
How would i go about changing values in pixels in an area? Note, all pixels will have the same value. I was thinking of using unsafe code to visit every single pixel in that area, but that may be too slow if i do this multiple time.
YOU CAN USE SetPixel() Bitmap bitmap = new Bitmap(@"C://1.bmp"); Color newColor = Color.FromArgb(0, 0,100); bitmap.SetPixel(i, j, newColor);
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
-
How would i go about changing values in pixels in an area? Note, all pixels will have the same value. I was thinking of using unsafe code to visit every single pixel in that area, but that may be too slow if i do this multiple time.
What's an "area"? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
How would i go about changing values in pixels in an area? Note, all pixels will have the same value. I was thinking of using unsafe code to visit every single pixel in that area, but that may be too slow if i do this multiple time.
You have two "easy" options: * http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fillrectangle.aspx[^] * directly accessing the pixels via an unmanaged pointer in an
unsafe
block I suggest you try both methods and see which one is faster. The fastest approach would probably be to set up a DirectX graphics device and render the area using a custom pixel shader. Depending on your needs this might be a bit overkill, though. regards -
What's an "area"? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
That's IT! I'm going to lunch!
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
You have two "easy" options: * http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fillrectangle.aspx[^] * directly accessing the pixels via an unmanaged pointer in an
unsafe
block I suggest you try both methods and see which one is faster. The fastest approach would probably be to set up a DirectX graphics device and render the area using a custom pixel shader. Depending on your needs this might be a bit overkill, though. regardsI set a specific value of intensity (for greyscale) or color within that region so fillrectangle is out of the question. So i guess unsafe is the way to go. As far as DirectX goes, I have no idea how to set it up. To answer the question above, an "area" is considered a portion of an image. Hence an area or region.
-
I set a specific value of intensity (for greyscale) or color within that region so fillrectangle is out of the question. So i guess unsafe is the way to go. As far as DirectX goes, I have no idea how to set it up. To answer the question above, an "area" is considered a portion of an image. Hence an area or region.
Can you express this area as a Region (System.Drawing)? If so can you create a Region from the image and use Graphics.FillRegion()?
gigahertz205 wrote:
I set a specific value of intensity (for greyscale) or color within that region so fillrectangle is out of the question.
What do you mean by that? Your original post stated all the pixels in the area will be the same color. You can use any color brush you want to with FillRectangle() :confused: Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
How would i go about changing values in pixels in an area? Note, all pixels will have the same value. I was thinking of using unsafe code to visit every single pixel in that area, but that may be too slow if i do this multiple time.
-
How would i go about changing values in pixels in an area? Note, all pixels will have the same value. I was thinking of using unsafe code to visit every single pixel in that area, but that may be too slow if i do this multiple time.