How can I determine position and size of rectangle on my image and fill rectangle with my texture using System.Drawing class or something else?

Basically I have to change the color of the particular part of an image on button click. Any idea how to do this?

Recommended Answers

All 6 Replies

This is so vague. what defines a "particular part"? the idea is to just create a rectangle at "some particular location" then create a graphics object from the image then call its FillRectangle() method.

Can you be more specific: what does your image contain? ie, is it a white background with a rectangle on it which you wish to fill or is it an actual image that you need to search for a particular part of?

This is so vague. what defines a "particular part"? the idea is to just create a rectangle at "some particular location" then create a graphics object from the image then call its FillRectangle() method.

I am afraid that I need more that. I need to change color of the selected object on the picture. So basically I need to define a "particular part". I need to import picture to my windows control and select part of the object and than on button click to fill that part with the selected color. This is something that you can easily do with Flash and AS3 but I need to do something like that with C#. I am not sure that you understand me what I need to do?

Can you be more specific: what does your image contain? ie, is it a white background with a rectangle on it which you wish to fill or is it an actual image that you need to search for a particular part of?

It is an actual image. I dont have to search for a particualar part of an image, I need to mark a particular part of an image(before running program) and later on button click fill that part with selected color or texture. This is something that you can easily do with Flash and AS3.

how do you intend to mark it?
You could use some sort of pixel matching technique; search the image pixel by pixel to find any that match the area you have 'marked'

Still unclear what you expecting. Do you just want to draw a rectangle with your mouse?

"this is something you can do easily with flash" Unfortunately flash is a scripting Language on a multimedia platform. C# can be so much more than a program trapped in plug-in. But that comes with having to learn more than just how to manipulate multimedia.

if you could explain exactly what you want to do, we can help you figure out how to accomplish it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.