Hello, I don’t know which way to approach ... I have a picture that I get from the server, there is such a plugin http://odyniec.net/projects/imgareaselect/, it all works, then I select a piece of the picture, data sent to the server and so d ... With this question, no.

The fact is that it is necessary to limit the selection area to make it possible to select not the whole picture, but only part of it. For example, I received a picture and let me select only a specific area, here’s more clearly http://dl.dropbox.com/u/26399837/ Forums / flower2.jpg

Here is my code to select the entire image. I use jQuery.

<head> <script type="text/javascript" src="./jQuery/jquery-1.7.2.js"></script> <link rel="stylesheet" type="text/css" href="./jQuery/imgareaselect-0.9.8/css/imgareaselect-default.css" /> <script type="text/javascript" src="./jQuery/imgareaselect-0.9.8/scripts/jquery.min.js"></script> <script type="text/javascript" src="./jQuery/imgareaselect-0.9.8/scripts/jquery.imgareaselect.pack.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#target').imgAreaSelect({ handles : true, movable : false, resizable : false, autoHide : true, onSelectEnd : function(img, selection){ $("#target").attr("src","/JFreeeChartServlet/generateImg?x1=" + selection.x1 + "&y1=" + selection.y1 + "&x2=" + selection.x2 + "&y2=" + selection.y2 + "&width=" + selection.width + "&height=" + selection.height); } }); }); </script> <title>JFreeChart_Bsp</title> </head> <body> <img src="/JFreeeChartServlet/generateImg" id="target" alt="generateImg" height="750" width="1450" /> </body> 


    1 answer 1

    This plugin has documentation, and not the worst. It follows from this that you can follow the onSelectChange event, just as you follow onSelectEnd . So in onSelectChange, you can compare selection.y1, y2, x1, x2 with the zone allowed by the user, and if the user got out, use the API method setSelection (note that you need to pass the instance: true when initializing the plug-in) so that the frame returns to the maximum allowed region.

    • More precisely - there are parameters for the selection area> maxHeight Maximum selection height (in pixels)>> maxWidth Maximum selection width (in pixels) - Deonis
    • you also need the position of this area and not only its size. - rnd_d
    • rnd_d An interesting approach .. But I just need it to not just let the selection go any further than necessary ... Since, for example, they make the maxHeight and maxWidth properties: These properties allow you to select an area no larger than maxHeight and maxWidth! And I need to define such an area in the picture, so that only within this area it was possible to select. The situation is such that there is a schedule that needs to be allocated, and I have a picture on which, besides the diagram, there is also a legend and an axis, and so on. Thank you. - JDev