View Full Version : DOF calculator for Blackberry
aram535
6th of July 2008 (Sun), 12:07
I recently chucked out my WinMobile and device and switched to Blackberry. I had all sorts of calculators on the old device, but I can't seem to find any for the BB. Does anyone have any links they can share?
If not, anyone have the formulas used for DOF calculations? I am willing to write one for the BB in java and distribute it freely.
eddarr
6th of July 2008 (Sun), 12:15
You can run the excel versions of the calculators on BB. But you have to get on of the 3rd party softwares that will open it on the BB. Several can be found on the BB website but their not cheap.
monty28428
6th of July 2008 (Sun), 13:08
Might give this one a shot: Link (http://handheld.softpedia.com/get/Photo/Depth-of-Field-Calculator-62082.shtml)
Haven't tried it myself as my BB stays home when I'm not working :-)
aram535
7th of July 2008 (Mon), 08:47
Might give this one a shot: Link (http://handheld.softpedia.com/get/Photo/Depth-of-Field-Calculator-62082.shtml)
Haven't tried it myself as my BB stays home when I'm not working :-)
First one I tried, but if you actually follow the link the author has pulled it off. Says it will be back next year, but the post could be from 2003 so who knows.
I'm lucky its a personal BB no work email on it.
monty28428
7th of July 2008 (Mon), 08:58
Sorry about that -- did you look at this one as well http://www.smartphone.net/software_detail.asp?id=2475&associateid=281
20droger
7th of July 2008 (Mon), 09:48
Actual and shortcut DoF formulas can be found here, (http://doug.kerr.home.att.net/pumpkin/Depth_of_Field.pdf) along with much information.
aram535
7th of July 2008 (Mon), 10:04
Just in case someone else was looking for it. Found one at:
http://www.jibble.org/dofcalc/
AkaChuck
14th of May 2011 (Sat), 20:27
You don't really need an application to do simple math calculations like a DOF calculator. A simple JavaScript file will work.
To make it work on a Blackberry device, simply copy contents of the file below from <HTML> to </HTML> and save it to a file for example DOFCalc.html file and then copy it to the BB device (or any device) via USB cable.
For example I copied it to backberry/documents/DOFCalc.html
and then open the Blackberry browser and open the file by typing in the location of the file in the URL
For example
file:///SDCard/blackberry/documents/DOFCalc.html
Blackberry is case sensitive and make sure JavaScript is enabled. Then Bookmark it so you can easily access it.
The calculator will calculate in feet, however, by changing one line of code in the HTML file feet = true to feet = false it will calculate in meters. Let me know if you have any issues.
<html>
<title>Depth Of Field Calculator</title>
<body>
<script type="text/javascript" LANGUAGE="JavaScript">
function doField(form) {
feet = true; // change true to false if meters is desired
if (feet){
distance = (form.distance.value)*1000*0.3048; //convert feet to millimeters
}else{
distance = (form.distance.value)*1000; //convert meters to millimeters
}
CoC = (document.form.format.options[document.form.format.selectedIndex].value);
aperture = (document.form.aperture.options[document.form.aperture.selectedIndex].value);
focal = (document.form.focal.options[document.form.focal.selectedIndex].value);
if (isNaN(distance)) {
alert('Please enter a numerical value for subject distance.');
document.form.distance.focus();
document.form.distance.select();
}
else {
hyperFocal = ((focal * focal) / (aperture * CoC)) + Math.round(focal);
if (feet){
form.hyperFocal.value = Math.round(hyperFocal / (1000*0.3048)) + " ft";
form.hyperFocal2.value = Math.round(hyperFocal / (1000*0.3048)) + " ft";
}else{
form.hyperFocal.value = (Math.round(hyperFocal) / 1000) + " m";
form.hyperFocal2.value = (Math.round(hyperFocal) / 1000) + " m";
}
dofNear = ((hyperFocal - focal) * distance) / (hyperFocal + (distance - (2 * focal)));
if (feet){
form.dofNear.value = Math.round(dofNear / (1000*0.3048)) + " ft";
}else{
form.dofNear.value = Math.round(dofNear) / 1000 + " m";
}
dofNear2 = (hyperFocal * hyperFocal) / (hyperFocal + (hyperFocal - focal));
if (feet){
form.dofNear2.value = Math.round(dofNear2 / (1000*0.3048)) + " ft";
}else{
form.dofNear2.value = (Math.round(dofNear2) / 1000) + " m";
}
dofFar = ((hyperFocal - focal) * distance) / (hyperFocal - distance);
if (dofFar < 0) {
form.dofFar.value = "Infinity.";
}
else {
if (feet){
form.dofFar.value = Math.round(dofFar/(1000*0.3048)) +" ft";
}else{
form.dofFar.value = Math.round(dofFar)/1000 +" m";
}
}
dofTotal = Math.round(dofFar - dofNear);
if (dofTotal < 0) {
form.dofTotal.value = "Infinite.";
}
else {
if (dofTotal >= 0 && dofTotal < 0.001) {
form.dofTotal.value = ">1 mm ";
}
else {
if (feet){
form.dofTotal.value = Math.round(dofTotal / (1000*0.3048)) + " ft";
}else{
form.dofTotal.value = dofTotal / 1000 + " m";
}
}
}
}
}
</script>
<center>
<form action="" method="post" name="form">
<table border="1" cellpadding="1" cellspacing="0" width="400">
<tr>
<td align="center" colspan="2">
Depth of Field Calculator
</td>
</tr>
<tr>
<td align="left">
Negative Format
</td>
<td align="left">
<select name="format">
<option value=0.03 style="font-size: 16px;font-weight: bold">35 mm
<option value=0.025 style="font-size: 16px;font-weight: bold">APS
<option value=0.05 style="font-size: 16px;font-weight: bold">6x45 cm
<option value=0.06 style="font-size: 16px;font-weight: bold">6x6 cm
<option value=0.065 style="font-size: 16px;font-weight: bold">6x7 cm
<option value=0.15 style="font-size: 16px;font-weight: bold">5x4 inch
<option value=0.3 style="font-size: 16px;font-weight: bold">10x8 inch
</select>
</td>
</tr>
<tr>
<td align="left">
Lens focal length
</td>
<td align="left">
<select name="focal">
<option value=24 style="font-size: 16px;font-weight: bold">24 mm
<option value=26 style="font-size: 16px;font-weight: bold">26 mm
<option value=28 style="font-size: 16px;font-weight: bold">28 mm
<option value=30 style="font-size: 16px;font-weight: bold">30 mm
<option value=35 style="font-size: 16px;font-weight: bold">35 mm
<option value=40 style="font-size: 16px;font-weight: bold">40 mm
<option value=45 style="font-size: 16px;font-weight: bold">45 mm
<option value=50 style="font-size: 16px;font-weight: bold">50 mm
<option value=55 style="font-size: 16px;font-weight: bold">55 mm
<option value=60 style="font-size: 16px;font-weight: bold">60 mm
<option value=70 style="font-size: 16px;font-weight: bold">70 mm
<option value=80 style="font-size: 16px;font-weight: bold">80 mm
<option value=100 style="font-size: 16px;font-weight: bold">100 mm
<option value=135 style="font-size: 16px;font-weight: bold">135 mm
<option value=150 style="font-size: 16px;font-weight: bold">150 mm
<option value=200 style="font-size: 16px;font-weight: bold">200 mm
</select>
</td>
</tr>
<tr>
<td align="left">
Selected aperture
</td>
<td align="left">
<select name="aperture">
<option value=2.8 style="font-size: 16px;font-weight: bold">F 2.8
<option value=3.2 style="font-size: 16px;font-weight: bold">F 3.2
<option value=4 style="font-size: 16px;font-weight: bold">F 4
<option value=5.6 style="font-size: 16px;font-weight: bold">F 5.6
<option value=8 style="font-size: 16px;font-weight: bold">F 8
<option value=11 style="font-size: 16px;font-weight: bold">F 11
<option value=14 style="font-size: 16px;font-weight: bold">F 14
<option value=16 style="font-size: 16px;font-weight: bold">F 16
<option value=18 style="font-size: 16px;font-weight: bold">F 18
<option value=20 style="font-size: 16px;font-weight: bold">F 20
<option value=22 style="font-size: 16px;font-weight: bold">F 22
<option value=32 style="font-size: 16px;font-weight: bold">F 32
<option value=45 style="font-size: 16px;font-weight: bold">F 45
</select>
</td>
</tr>
<tr>
<td align="left">
Subject distance
</td>
<td align="left">
<input type="text" name="distance" value="" size="8">
<input type="button" value="Calculate" onclick="doField(this.form)">
</td>
</tr>
<tr>
<td colspan="2" align="left">
<center>Focus at <input name="hyperFocal2" type="text" value="" size=5 style="font-size: 16px;font-weight: bold"> for focus from <input name="dofNear2" type="text" value="" size=5 style="font-size: 16px;font-weight: bold"> to infinity.</center>
<br>
<input name="hyperFocal" type="text" value="" size=12 style="font-size: 16px;font-weight: bold"> Hyperfocal distance for infinity.
<BR>
<input name="dofNear" type="text" value="" size=12 style="font-size: 16px;font-weight: bold"> Near limit of acceptable sharpness.
<BR>
<input name="dofFar" type="text" value="" size=12 style="font-size: 16px;font-weight: bold"> Far limit of acceptable sharpness.
<BR>
<input name="dofTotal" type="text" value="" size=12 style="font-size: 16px;font-weight: bold"> Total depth of field.
<BR>
</td></tr>
</table>
</form>
</center>
</body>
</html>
AkaChuck
15th of May 2011 (Sun), 18:05
Sorry I found some errors. The value for the F stops need to match. The lines that need to be fixed are:
<option value=14 style="font-size: 16px;font-weight: bold">F 14
<option value=16 style="font-size: 16px;font-weight: bold">F 16
<option value=18 style="font-size: 16px;font-weight: bold">F 18
<option value=20 style="font-size: 16px;font-weight: bold">F 20
<option value=22 style="font-size: 16px;font-weight: bold">F 22
<option value=32 style="font-size: 16px;font-weight: bold">F 32
<option value=45 style="font-size: 16px;font-weight: bold">F 45
emelvee
15th of May 2011 (Sun), 18:06
Wow.
SkipD
16th of May 2011 (Mon), 08:50
Sorry I found some errors. The value for the F stops need to match. The lines that need to be fixed are:
<option value=14 style="font-size: 16px;font-weight: bold">F 14
<option value=16 style="font-size: 16px;font-weight: bold">F 16
<option value=18 style="font-size: 16px;font-weight: bold">F 18
<option value=20 style="font-size: 16px;font-weight: bold">F 20
<option value=22 style="font-size: 16px;font-weight: bold">F 22
<option value=32 style="font-size: 16px;font-weight: bold">F 32
<option value=45 style="font-size: 16px;font-weight: bold">F 45Why don't you just go to your original post and edit the errors out?
boclcown
16th of May 2011 (Mon), 15:27
....A simple...
:-o
Blurr Cube
16th of May 2011 (Mon), 16:37
Simple? or BASIC? or Greek? :confused:
Jason Paul
17th of May 2011 (Tue), 09:17
Chuck,
Thanks for that. I haven't put it on my BB yet (currently at work), but did create the file on my PC (with the changes from your second post), and it seems to work fine.
One question though - what would need to be changed to keep it from rounding to full numbers? What if I wanted to have it round to the 100th's place (.01), or even the tenth's place (.1)?
I'm not a programmer, but have worked a bit with code (a little html & php in WordPress).
Thanks,
Jason
By the way, below is the CORRECTED Code, per Chuck's second post. For your PC, just copy and paste this into WordPad (or Notepad), and save it as a .html file (eg. DOFCalculator.html). When you open it, it should open in your browser, and work. As I haven't put this on my Blackberry, I'm not sure of the exact procedure, but I assume it's just as Chuck says above. Just put the .html file on your BB, open it with your browser, and bookmark it. When you need it, just open your browser and go to the bookmark. Here's the code (again, I've corrected the code per Chuck's second post:
<html>
<title>Depth Of Field Calculator</title>
<body>
<script type="text/javascript" LANGUAGE="JavaScript">
function doField(form) {
feet = true; // change true to false if meters is desired
if (feet){
distance = (form.distance.value)*1000*0.3048; //convert feet to millimeters
}else{
distance = (form.distance.value)*1000; //convert meters to millimeters
}
CoC = (document.form.format.options[document.form.format.selectedIndex].value);
aperture = (document.form.aperture.options[document.form.aperture.selectedIndex].value);
focal = (document.form.focal.options[document.form.focal.selectedIndex].value);
if (isNaN(distance)) {
alert('Please enter a numerical value for subject distance.');
document.form.distance.focus();
document.form.distance.select();
}
else {
hyperFocal = ((focal * focal) / (aperture * CoC)) + Math.round(focal);
if (feet){
form.hyperFocal.value = Math.round(hyperFocal / (1000*0.3048)) + " ft";
form.hyperFocal2.value = Math.round(hyperFocal / (1000*0.3048)) + " ft";
}else{
form.hyperFocal.value = (Math.round(hyperFocal) / 1000) + " m";
form.hyperFocal2.value = (Math.round(hyperFocal) / 1000) + " m";
}
dofNear = ((hyperFocal - focal) * distance) / (hyperFocal + (distance - (2 * focal)));
if (feet){
form.dofNear.value = Math.round(dofNear / (1000*0.3048)) + " ft";
}else{
form.dofNear.value = Math.round(dofNear) / 1000 + " m";
}
dofNear2 = (hyperFocal * hyperFocal) / (hyperFocal + (hyperFocal - focal));
if (feet){
form.dofNear2.value = Math.round(dofNear2 / (1000*0.3048)) + " ft";
}else{
form.dofNear2.value = (Math.round(dofNear2) / 1000) + " m";
}
dofFar = ((hyperFocal - focal) * distance) / (hyperFocal - distance);
if (dofFar < 0) {
form.dofFar.value = "Infinity.";
}
else {
if (feet){
form.dofFar.value = Math.round(dofFar/(1000*0.3048)) +" ft";
}else{
form.dofFar.value = Math.round(dofFar)/1000 +" m";
}
}
dofTotal = Math.round(dofFar - dofNear);
if (dofTotal < 0) {
form.dofTotal.value = "Infinite.";
}
else {
if (dofTotal >= 0 && dofTotal < 0.001) {
form.dofTotal.value = ">1 mm ";
}
else {
if (feet){
form.dofTotal.value = Math.round(dofTotal / (1000*0.3048)) + " ft";
}else{
form.dofTotal.value = dofTotal / 1000 + " m";
}
}
}
}
}
</script>
<center>
<form action="" method="post" name="form">
<table border="1" cellpadding="1" cellspacing="0" width="400">
<tr>
<td align="center" colspan="2">
Depth of Field Calculator
</td>
</tr>
<tr>
<td align="left">
Negative Format
</td>
<td align="left">
<select name="format">
<option value=0.03 style="font-size: 16px;font-weight: bold">35 mm
<option value=0.025 style="font-size: 16px;font-weight: bold">APS
<option value=0.05 style="font-size: 16px;font-weight: bold">6x45 cm
<option value=0.06 style="font-size: 16px;font-weight: bold">6x6 cm
<option value=0.065 style="font-size: 16px;font-weight: bold">6x7 cm
<option value=0.15 style="font-size: 16px;font-weight: bold">5x4 inch
<option value=0.3 style="font-size: 16px;font-weight: bold">10x8 inch
</select>
</td>
</tr>
<tr>
<td align="left">
Lens focal length
</td>
<td align="left">
<select name="focal">
<option value=24 style="font-size: 16px;font-weight: bold">24 mm
<option value=26 style="font-size: 16px;font-weight: bold">26 mm
<option value=28 style="font-size: 16px;font-weight: bold">28 mm
<option value=30 style="font-size: 16px;font-weight: bold">30 mm
<option value=35 style="font-size: 16px;font-weight: bold">35 mm
<option value=40 style="font-size: 16px;font-weight: bold">40 mm
<option value=45 style="font-size: 16px;font-weight: bold">45 mm
<option value=50 style="font-size: 16px;font-weight: bold">50 mm
<option value=55 style="font-size: 16px;font-weight: bold">55 mm
<option value=60 style="font-size: 16px;font-weight: bold">60 mm
<option value=70 style="font-size: 16px;font-weight: bold">70 mm
<option value=80 style="font-size: 16px;font-weight: bold">80 mm
<option value=100 style="font-size: 16px;font-weight: bold">100 mm
<option value=135 style="font-size: 16px;font-weight: bold">135 mm
<option value=150 style="font-size: 16px;font-weight: bold">150 mm
<option value=200 style="font-size: 16px;font-weight: bold">200 mm
</select>
</td>
</tr>
<tr>
<td align="left">
Selected aperture
</td>
<td align="left">
<select name="aperture">
<option value=2.8 style="font-size: 16px;font-weight: bold">F 2.8
<option value=3.2 style="font-size: 16px;font-weight: bold">F 3.2
<option value=4 style="font-size: 16px;font-weight: bold">F 4
<option value=5.6 style="font-size: 16px;font-weight: bold">F 5.6
<option value=8 style="font-size: 16px;font-weight: bold">F 8
<option value=11 style="font-size: 16px;font-weight: bold">F 11
<option value=14 style="font-size: 16px;font-weight: bold">F 14
<option value=16 style="font-size: 16px;font-weight: bold">F 16
<option value=18 style="font-size: 16px;font-weight: bold">F 18
<option value=20 style="font-size: 16px;font-weight: bold">F 20
<option value=22 style="font-size: 16px;font-weight: bold">F 22
<option value=32 style="font-size: 16px;font-weight: bold">F 32
<option value=45 style="font-size: 16px;font-weight: bold">F 45
</select>
</td>
</tr>
<tr>
<td align="left">
Subject distance
</td>
<td align="left">
<input type="text" name="distance" value="" size="8">
<input type="button" value="Calculate" onclick="doField(this.form)">
</td>
</tr>
<tr>
<td colspan="2" align="left">
<center>Focus at <input name="hyperFocal2" type="text" value="" size=5 style="font-size: 16px;font-weight: bold"> for focus from <input name="dofNear2" type="text" value="" size=5 style="font-size: 16px;font-weight: bold"> to infinity.</center>
<br>
<input name="hyperFocal" type="text" value="" size=12 style="font-size: 16px;font-weight: bold"> Hyperfocal distance for infinity.
<BR>
<input name="dofNear" type="text" value="" size=12 style="font-size: 16px;font-weight: bold"> Near limit of acceptable sharpness.
<BR>
<input name="dofFar" type="text" value="" size=12 style="font-size: 16px;font-weight: bold"> Far limit of acceptable sharpness.
<BR>
<input name="dofTotal" type="text" value="" size=12 style="font-size: 16px;font-weight: bold"> Total depth of field.
<BR>
</td></tr>
</table>
</form>
</center>
</body>
</html>
AkaChuck
17th of May 2011 (Tue), 18:48
Thanks JasonPaul for the corrections. As you can tell I'm new to this forum. I did go back and made the corrections on my post. So hopefully that will end any confusion. I'm a programmer by trade and wanted a simple program to perform DOF calculations. In my search there were many out there with heavy advertising, needed to be tethered to a data network and/or wanted money. Originally I coded it it Blackberry OS, but realized that BB was not consistent across all platforms. After doing more research I learned that BB doesn't even support all of JavaScript consistently. Originally I had a radio button to toggle between calculations in Feet and Meters, but the radio button in JavaScript wasn't supported in my version of BB OS. Needless to say I broke down the DOF calculator to its minimum. The feet or meters calculation is still available by setting the Boolean value feet = true; to feet = false; I believe in its current form it will work on any device that has a browser and supports JavaScript. This will be my last Blackberry, I'm disappointed with RIM. Let me know if you have any issues with the DOF calculator. Enjoy.
vBulletin® v3.6.12, Copyright ©2000-2013, Jelsoft Enterprises Ltd.