|
Member 12551418 wrote: Many people will be grateful if any of you could work on it. Including you because we would be doing your job for you for free. That's not the way this place works.
Now, you could always search in Google to see if anyone has already written something that does this. Bearing in mind that JCrop[^] already does most of the work for you, it doesn't seem unreasonable to expect you to put a little bit of effort into it yourself.
This space for rent
|
|
|
|
|
sorry i was just a student I have already had a search in google but I found those in PHP so I thought of asking here.
If u think it as a mistake please accept my apologies
Sorry for using CODEPROJECT
|
|
|
|
|
You can use CodeProject all you like but you have to realise that members physically couldn't cope with the number of requests for code that come in. What you need to do is break down the effect you are trying to achieve into simple steps - something like this:
1. Get the rectangle from the image that the user has selected.
2. Upload the image along with the rectangle.
3. At the server side, load the image into a temporary bitmap object
4. Apply the same rectangle and crop to it
5. Save the cropped image.
When you break things down like that, you see that things aren't quite as hard, and it shows you what areas you are going to have to research. For instance, cropping a bitmap could be accomplished using the technique here[^].
This space for rent
|
|
|
|
|
<script type="text/javascript"></script>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>>
<script src="~/Scripts/jquery.Jcrop.js"></script>
<script src="~/Scripts/jquery.Jcrop.min.js"></script>
<link href="~/Content/jquery.Jcrop.min.css" rel="stylesheet" />
<form id="form1">
<input type='file' id="imgInp" />
<img id="blah" class="crop" src="#" alt="your image" />
<input type="hidden" id="x" name="x" />
<input type="hidden" id="y" name="y" />
<input type="hidden" id="w" name="w" />
<input type="hidden" id="h" name="h" />
</form>
<style>
#blah {
background-color: #FFF;
width: 500px;
height: 330px;
font-size: 24px;
display: block;
}
</style>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
$('.crop').Jcrop({
onSelect: updateCoords,
bgOpacity: .4,
setSelect: [100, 100, 50, 50],
aspectRatio: 16 / 9
});
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function () {
console.log(this);
readURL(this);
});
function updateCoords(c) {
console.log(c);
$('#x').val(c.x);
$('#y').val(c.y);
$('#w').val(c.w);
$('#h').val(c.h);
};
By using this i'm getting "Uncaught TypeError: $(...).Jcrop is not a function"
How could I solve this?
|
|
|
|
|
That's JavaScript and this is a C# forum.
This space for rent
|
|
|
|
|
- This is nothing to do with C#;
- You're including both
jquery.Jcrop.js and jquery.Jcrop.min.js - you only need one of those; - You can't use app-relative paths (
~/... ) in a <script> tag;
If you're using WebForms:
<script src="<%= ResolveUrl("~/Scripts/jquery-1.10.2.min.js") %>"></script>
<script src="<%= ResolveUrl("~/Scripts/jquery.Jcrop.min.js") %>"></script>
<link href="<%= ResolveUrl("~/Content/jquery.Jcrop.min.css") %>" rel="stylesheet" />
If you're using MVC:
<script src="@Url.Content("~/Scripts/jquery-1.10.2.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.Jcrop.min.js")"></script>
<link href="@Url.Content("~/Content/jquery.Jcrop.min.css")" rel="stylesheet" />
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
|
here is my table sql :
user----------term
John..........diligent
Jane..........new
I have a variable : termUser
and I find easily its value by Sql request when the user is saved it in the mysql table and this user see his term on the screen by (due to) the variable : termUser.
I try it by 2 way ( by if condition) and those way are correct results
string termUser = String.Empty;
string catchTerm = String.Empty;
while (dataMySqlReader.Read())
{
catchTerm = (string)dataMySqlReader["user"];
if (catchTerm != null)
{
termUser = (string)dataMySqlReader["term"];
}
else
{
termUser = "callow";
}
if (String.IsNullOrEmpty(catchTerm))
{
termUser = "callow";
}
else
{
termUser = (string)dataMySqlReader["term"];
}
}
If the user is not in the mysql table, I think that SQL return 'NULL', so in this case, I want to affect this variable (termUser) by 'callow' : It's only for to display on his monitor.
But my code can not affect my variable.
I changed also my condition but I have not success by this :
if (String.IsNullOrEmpty(catchTerm))
<pre>
if (string.IsNullOrEmpty(catchTerm) == true)
</pre>
how I can affect my variable termUser by 'callow when the user is not in my table ?
Thanks
|
|
|
|
|
A "null" value in a database is not the same an empty string; you might want to compare to <a href="https://msdn.microsoft.com/nl-nl/library/system.dbnull.value%28v=vs.110%29.aspx">DBNull.Value</a>[<a href="https://msdn.microsoft.com/nl-nl/library/system.dbnull.value%28v=vs.110%29.aspx" target="_blank" title="New Window">^</a>] .
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: A "null" value in a database is not the same an empty string You haven't ever worked with an Oracle DB, have you? 
|
|
|
|
|
Aw, I did, but it has been a while since Oracle 7 and selecting from 'dual'
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I believe this works in Oracle too?
If issues, please explain, you made me curious...
|
|
|
|
|
Well, look at it from a different perspective. Imagine a questionnaire. Someone left a free-text field empty. Does that translate to a null value or string.Empty ? Hence an empty string and a null string are the same in an Oracle database. If there's a "not null" constraint on the text field, you cannot insert an empty string either.
At first, I thought that's a WTF. But now I think they got it right.
|
|
|
|
|
As Eddy Vluggen mentioned:
if(dataMySqlReader["user"] != DBNull.Value){
}
else{
}
hope this helps.
modified 1-Jun-16 7:32am.
|
|
|
|
|
Won't that produce an InvalidCastException if the field is null?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Oops, my copy/paste error ...
I'll fix that...
|
|
|
|
|
Thanks but it does not work
|
|
|
|
|
What does "not work" mean exactly?
Did it throw an error? If yes, what was the message?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
my variable can not affected
|
|
|
|
|
Show us some updated code, maybe we could talk about it
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
What's the error ?
Why doesn't it work?
|
|
|
|
|
But this version works !
it is very strange
string termUser = String.Empty;
termUser = "callow";
string catchTerm = String.Empty;
while (dataMySqlReader.Read())
{
catchTerm = (string)dataMySqlReader["user"];
if (catchTerm != null)
{
termUser = (string)dataMySqlReader["term"];
}
}
|
|
|
|
|
if dataMySqlReader["user"] is null this thing will crash I think...
Note that I updated my previous answer by removing the string cast (that was a copy/paste error)...
also this:
string termUser = String.Empty;
termUser = "callow";
is useless, use:
string termUser = "callow";
|
|
|
|
|
but
My variable [termUser] is affected by "callow" with this code :
it is very strange
string termUser = String.Empty;
termUser = "callow";
string catchTerm = String.Empty;
while (dataMySqlReader.Read())
{
catchTerm = (string)dataMySqlReader["user"];
if (catchTerm != null)
{
termUser = (string)dataMySqlReader["term"];
}
}
|
|
|
|