473,657 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Take coordinates form image

Hello,
I have a simple problem: mark a list of defects
on an image.

I think the best way to do it is to select a single
deffect, then take two coordinates of coursor
form an image on a web page (first when user press
the button, and the second when he releases it).
Those two points are going to be send to the web
application (i.e. with AJAX) and saved in a database.
Later, I will use those points to render
the image with RMagic (drawing the lines and defects
list numbers on top of the image).

Any suggestions how to do it?

Even a chapter in a book, or enything
what could get me started is welcomed.

Best regards,
Tom
Nov 23 '05 #1
4 2448
"Tomasz Bak" <op*******@wp.p l> wrote in message
news:dl******** **@nemesis.news .tpi.pl...
Hello,
I have a simple problem: mark a list of defects
on an image.

I think the best way to do it is to select a single
deffect, then take two coordinates of coursor
form an image on a web page (first when user press
the button, and the second when he releases it).
Those two points are going to be send to the web
application (i.e. with AJAX) and saved in a database.
Later, I will use those points to render
the image with RMagic (drawing the lines and defects
list numbers on top of the image).

Any suggestions how to do it?

Even a chapter in a book, or enything
what could get me started is welcomed.

Best regards,
Tom


Will this help? Watch for word-wrap.

<html>
<head>
<title>coords.h tm</title>
<script type="text/javascript">
function coords() {
var f = document.forms[0];
var x = window.event.sc reenX;
var y = window.event.sc reenY;
if (f.xy1.value == "") {
f.xy1.value = x + "," + y;
} else {
f.xy2.value = x + "," + y;
}
}
</script>
</head>
<body>
<img src="http://www.google.com/intl/en/images/logo.gif"
border="1" width="276" height="110" alt="" onclick="coords ()">
<form>
<br><input type="text" name="xy1" size="9" value="">
<br><input type="text" name="xy2" size="9" value="">
<br><input type="reset" value="Reset">
</form>
</body>
</html>
Nov 23 '05 #2
McKirahan wrote:
"Tomasz Bak" <op*******@wp.p l> wrote in message
news:dl******** **@nemesis.news .tpi.pl...
Hello,
I have a simple problem: mark a list of defects
on an image.

I think the best way to do it is to select a single
deffect, then take two coordinates of coursor
form an image on a web page (first when user press
the button, and the second when he releases it).
Those two points are going to be send to the web
application (i.e. with AJAX) and saved in a database.
Later, I will use those points to render
the image with RMagic (drawing the lines and defects
list numbers on top of the image).

Any suggestions how to do it?

Even a chapter in a book, or enything
what could get me started is welcomed.

Best regards,
Tom

Will this help? Watch for word-wrap.


If the solution is only for browsers implementing the IE event model and
window properties, and if the position is to be relative to the entire
screen, then yes.

But if the solution needs to be cross-browser and the coordinates
relative to the image, the script below may suit better. Note that IE
does not include the default body padding/margin in the offset, so it
must be set to some value (say zero) or the element absolutely
positioned - otherwise the coordinates will be out by whatever the IE
default is (about left 13px and top 17px).

The following script it a quick hack from bits I had lying around: it
will only draw a box from top left to bottom right; boxes can extend
beyond the image; event capturing and handling is probably not optimal
(well, almost certainly not); /et al/.

Quite a bit of further development is required but it gives the OP some
idea of the scope of what is being attempted.
<div id="mBox" style="position : absolute; border: 2px solid red;
display: none;"></div>

<img src="a.jpg"
border="1" width="276" height="110" alt=""
onmousedown="Do Measure.startMe asure(event, this)"
style="position : absolute; top: 100px; left: 100px;"><br>
<input type="button" value="Clear boxes"
onclick="DoMeas ure.clearBoxes( );">
<div id="msg"></div>

<script type="text/javascript">

var DoMeasure = ( function() {

var mBoxRoot = document.getEle mentById('mBox' );
var Boxes = [];
var msgDiv = document.getEle mentById('msg') ;
var docBody = document.body || document.docume ntElement;

function startMeasure(e, el)
{
var cPos = getCursorPos(e) ;
var box = mBoxRoot.cloneN ode(true);
Boxes[Boxes.length] = box;
box.style.displ ay = '';
box.id = '';
box.style.left = cPos.x + 'px';
box.style.top = cPos.y + 'px';
docBody.appendC hild(box);

var elPos = getElPos(el);

el.onmousemove = function() {stretchBox(e, cPos, box);}
el.onmouseup = stopMeasure;

// Event capture not need for 'zillas but important for IE
if ( el.captureEvent s ) { // Capture events 'zillas
el.captureEvent s(
Event.MouseDown | Event.MouseMove | Event.MouseUp
);
} else if ( el.setCapture ) { // Capture events IE
el.setCapture() ;
}

// Just for debug
msgDiv.innerHTM L = (cPos.x - elPos.x)+', '+(cPos.y - elPos.y);
}

// Return the position of event (cursor)
function getCursorPos(e)
{
if (e.pageX || e.pageY) return {x:e.pageX, y:e.pageY};
if (e.clientX || e.clientY) {
return {x:e.clientX + document.body.s crollLeft,
y:e.clientY + document.body.s crollTop};
}
}

// Return the top left position of an element
function getElPos(el)
{
var pos = {x:0, y:0};
if (el.offsetParen t){
while (el.offsetParen t){
pos.x += el.offsetLeft;
pos.y += el.offsetTop;
el = el.offsetParent ;
}
return pos;
}
if (el.x) return {x:el.x, y:el.y}
}

// Change the width & height of an element
function stretchBox(e, sPos, box)
{
var e = e || window.event;
var cPos = getCursorPos(e) ;
box.style.width = (cPos.x - sPos.x) + 'px';
box.style.heigh t = (cPos.y - sPos.y) + 'px';
}

// Cancel mousemove & cleanup
function stopMeasure(e)
{
var e = e || window.event;
this.onmousemov e = null;

if ( this.releaseEve nts ) { // Release events & capture
this.releaseEve nts(
Event.MouseDown | Event.MouseMove | Event.MouseUp
);
} else if ( this.releaseCap ture ) {
this.releaseCap ture();
}

var cPos = getCursorPos(e) ;
msgDiv.innerHTM L += '<br>' + cPos.x + ', ' + cPos.y;
}

return ({

// Start measuring on mousedown
startMeasure :
function(e, el){
var e = e || window.event;
startMeasure(e, el);
},

// Delete measurement boxes
clearBoxes :
function(){
var i = Boxes.length;
while(i--) Boxes[i].parentNode.rem oveChild(Boxes[i]);
Boxes.length = 0;
}
});
})();
</script>

--
Rob
Nov 23 '05 #3
RobG wrote:
McKirahan wrote:
"Tomasz Bak" <op*******@wp.p l> wrote in message
news:dl******** **@nemesis.news .tpi.pl...

Even a chapter in a book, or enything
what could get me started is welcomed.

Best regards,
Tom
Will this help? Watch for word-wrap. Thank you, it helps a lot to see a solution
in just a couple of lines!


If the solution is only for browsers implementing the IE event model and
window properties, and if the position is to be relative to the entire
screen, then yes.

Supporting other browsers is a good thing.
Especially as long as I dont use IE myself ;P

But if the solution needs to be cross-browser and the coordinates
relative to the image, the script below may suit better. Note that IE
does not include the default body padding/margin in the offset, so it
must be set to some value (say zero) or the element absolutely
positioned - otherwise the coordinates will be out by whatever the IE
default is (about left 13px and top 17px). Oki. I think I can open the image in another window
(there is some javascript call to open a popup I believe)
and the problem with relativness will disappear.

The following script it a quick hack from bits I had lying around: it
will only draw a box from top left to bottom right; boxes can extend
beyond the image; event capturing and handling is probably not optimal
(well, almost certainly not); /et al/.

Thats more than enough to get me going. Thanks!

Best regards,
Tom
Nov 23 '05 #4
On 2005-11-20, Tomasz Bak <op*******@wp.p l> wrote:
Hello,
I have a simple problem: mark a list of defects
on an image.

I think the best way to do it is to select a single
deffect, then take two coordinates of coursor
form an image on a web page (first when user press
the button, and the second when he releases it).
Those two points are going to be send to the web
application (i.e. with AJAX) and saved in a database.
Later, I will use those points to render
the image with RMagic (drawing the lines and defects
list numbers on top of the image).

Any suggestions how to do it?


capture the onmousedown and onmouseup events and extract the
coodinates from them (possibly subtracting the images left and top
coodinates to get a result relative to the image.

--

Bye.
Jasen
Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
7046
by: Tony Gahlinger | last post by:
I'm using my browser (Mozilla/5.0 Linux i686 Gecko/20031007 Firebird/0.7) to do some client-side image processing. I want to capture the sequence of coordinates a user clicks on in xxx.jpg in the following html <a href="#"><IMG SRC="xxx.jpg" ISMAP></a> and save these to a file for later handling. The coordinates appear on the bottom left of the window as I move the mouse, so I know they're being passed around somehow, but I haven't...
3
63389
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and display (in the status bar) the image coordinates of the mouse location. However, if I use the picturebox's MouseMove event, I am getting the coordinates of the mouse over the PICTUREBOX, not the actual image underneath that (which is stretched)....
0
3472
by: deko | last post by:
I'm trying to implement a custom TreeView that shows a ghost image while dragging. But the form I'm using is different from the sample code found here: http://www.codeproject.com/cs/miscctrl/TreeViewDragDrop.asp The problem is I can't get the proper coordinates required when dragging begins. I have two tree views in a panel with a splitter, and the panel is on a TabControl. The sample code just has a simple form with the treeview...
1
3387
by: emferrari | last post by:
Hi all I'm developing a windows form application that has a picturebox in which I'll load screen prints from a jpg file. I want the user to click in one point in the image and after the click fill two text boxes with the X and Y coordinates of that click, but the coordinates need to be based in the image only not in the whole form. I did not find anything that tells me about this in the internet. Does somebody here already did something...
8
2352
by: Bob Bedford | last post by:
Hello, I've some geographical coordinates and I'd like to put them on a map. Example: I've the map of the USA. Once I've selected Chicago, I'd like a point-cross or what ever, on the Chicago point over the map. How can this be done in PHP ? I know you can do everything in GD, but does something similar already exist
0
1154
by: nupur.agarwal29 | last post by:
Hi All, I have a web browse control hosted in a windows form. I want to calculate the coordinates of all the images present in the web page displayed in the webbrowser. I am adding all the documents(main document and the iframe/frame documents) in a HTMLDocument list on the NavigateComplete2Event. I am using GetClientRects() to find the coordiantes. is the main browser document( i.e. when browserControl.Document.url =
3
21254
by: jackiepatti | last post by:
QUESTION: I have a web page containing a form that contains an image instead of a submit button, e.g. <form name='myform' action='get' method='otherpage.asp'> <input type='image' src='picture.gif' name='myimage' id='myimage'> </form> When forms with image types are submitted, the value is not returned; instead, when the form is submitted, the XY coordinates of the where the user clicked on the image are sent. For example, if the user
3
22441
by: Andrzej | last post by:
I have a picturebox on my C# .NET form. The picturebox size mode is set to zoom. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and display (in the status bar) the image coordinates of the mouse location. However, if I use the picturebox's MouseMove event, I am getting the coordinates of the mouse over the PICTUREBOX, not the actual image underneath that (which is zoomed). i.e....
1
2306
by: Cainnech | last post by:
Hi all, I've got a bit of a challenge. I've got a script which displays the mouse coodinates if you click on an image. Now I would like to convert these coordinates to pixelnumber. Let me see if I can make it easier. Suppose we have an image which is 100px high and 100px wide. The coordinates of the upper left corner would be x=0 and y=0 The coordinates of the upper right corner would be x=99 and y=0 The coordinates of the lower left...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8516
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.