Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,
I have coordinates of image such as X1,Y1,X2 and Y2. I want to highlight image part based upon its coordinates. I googled it but I am not able to find solutions. Please help me.....
Posted
Updated 22-Jul-13 0:56am
v2
Comments
Herman<T>.Instance 22-Jul-13 6:24am    
Please share code. We cannot see what you have tried more.
Samresh.ss 22-Jul-13 6:38am    
What do you mean by highlight. Do you mean a zoomed in effect
enhzflep 22-Jul-13 7:15am    
Just draw a polyLine from each of the points to the next.
You may wish to fill a polygon with a semi-transparent colour before drawing the polyline.

Here's how I do it in javascript. A quick tour of MSDN will tell you the names of the (roughly) equivalent functions in c#.

// takes a string that contains coords eg - "227,307,261,309, 339,354, 328,371, 240,331"
// draws a line from each co-ord pair to the next - assumes starting point needs to be repeated as ending point.
function drawPoly(coOrdStr)
{
var mCoords = coOrdStr.split(',');
var i, n;
n = mCoords.length;

//c.fillStyle="#aaaaaa"
hdc.fillStyle = "rgba(255,0,0,0.3)";

hdc.beginPath();
hdc.moveTo(mCoords[0], mCoords[1]);
for (i=2; i<n; i+=2)
{
hdc.lineTo(mCoords[i], mCoords[i+1]);
}
hdc.lineTo(mCoords[0], mCoords[1]);
hdc.stroke();
hdc.fill();
}

The standard way to highlight selections in MS GUIs is to invert the colors. So what you do is get access to the image bitmap data (Work with bitmaps faster in C#[^]) and 1-complement the desired pixels.

Alternatively, you can think of increasing the luminance by multiplying all three color components by a common factor (say 1.33), but you will need to limit the factor to avoid saturation, that could induce a color drift. So in practice, use Min(1.33, 255. / Red, 255. / Green, 255. / Blue). For this reason, luminance enhancement will not work on already light areas.
 
Share this answer
 
Hi friends, thanks all for the suggestions. I found another solutions that link is....

http://odyniec.net/projects/imgareaselect/examples.html[^]
 
Share this answer
 
v2
Comments
Naz_Firdouse 23-Jul-13 8:37am    
updated the url with anchor tag instead of plain text
You can use cropperjs library. In that library there is method called "setCropBoxData(data)" you can set your co-ordinates and a cropper-box will be build on top of that co-ordinates. There are multiple options to change as your use case , I worked previously on that library.
Hope this helps.
link:-
https://www.npmjs.com/package/cropperjs
 
Share this answer
 
v2
Comments
OriginalGriff 3-Apr-24 1:34am    
While I applaud your urge to help people, it's a good idea to stick to new questions, rather than 11 year old ones. After that amount of time, it's unlikely that the original poster is at all interested in the problem any more!
Answering old questions can be seen as rep-point hunting, which is a form of site abuse. The more trigger happy amongst us will start the process of banning you from the site if you aren't careful. Stick to new questions and you'll be fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900