diff --git a/lib/commons-net-3.0.1.jar b/lib/commons-net-3.0.1.jar deleted file mode 100644 index 36ad489386633a331d2ec3b516b1b6a6787ade67..0000000000000000000000000000000000000000 Binary files a/lib/commons-net-3.0.1.jar and /dev/null differ diff --git a/lib/commons-net-3.1.jar b/lib/commons-net-3.1.jar new file mode 100644 index 0000000000000000000000000000000000000000..b75f1a51cc60108be7dd7e9d0e8a6fbbd3856203 Binary files /dev/null and b/lib/commons-net-3.1.jar differ diff --git a/src/com/t_oster/liblasercut/BlackWhiteRaster.java b/src/com/t_oster/liblasercut/BlackWhiteRaster.java index e00e73698c10034b9707805046205616c62f7abc..686a01e56758419d77583dbb0f72228150db1a61 100644 --- a/src/com/t_oster/liblasercut/BlackWhiteRaster.java +++ b/src/com/t_oster/liblasercut/BlackWhiteRaster.java @@ -18,11 +18,7 @@ **/ package com.t_oster.liblasercut; -import com.t_oster.liblasercut.dithering.Average; -import com.t_oster.liblasercut.dithering.DitheringAlgorithm; -import com.t_oster.liblasercut.dithering.FloydSteinberg; -import com.t_oster.liblasercut.dithering.Ordered; -import com.t_oster.liblasercut.dithering.Random; +import com.t_oster.liblasercut.dithering.*; /** * @@ -37,6 +33,7 @@ public class BlackWhiteRaster extends TimeIntensiveOperation AVERAGE, RANDOM, ORDERED, + GRID, } private int width; private int height; @@ -54,6 +51,8 @@ public class BlackWhiteRaster extends TimeIntensiveOperation return new Random(); case ORDERED: return new Ordered(); + case GRID: + return new Grid(); default: throw new IllegalArgumentException("Desired Dithering Algorithm ("+alg+") does not exist"); } diff --git a/src/com/t_oster/liblasercut/LibInfo.java b/src/com/t_oster/liblasercut/LibInfo.java index 65ae343f26b9e5a63be848ade37e6c0829853114..9e8e7be33c465f4a2029ca7da576427451443298 100644 --- a/src/com/t_oster/liblasercut/LibInfo.java +++ b/src/com/t_oster/liblasercut/LibInfo.java @@ -29,7 +29,7 @@ import com.t_oster.liblasercut.drivers.LaosCutter; */ public class LibInfo { - private static String VERSION = "1.4"; + private static String VERSION = "1.5"; public static String getVersion() { diff --git a/src/com/t_oster/liblasercut/dithering/Grid.java b/src/com/t_oster/liblasercut/dithering/Grid.java new file mode 100644 index 0000000000000000000000000000000000000000..c02acb8bf9d01806b6ed1430c77f1c6dcea31331 --- /dev/null +++ b/src/com/t_oster/liblasercut/dithering/Grid.java @@ -0,0 +1,66 @@ +/** + * This file is part of VisiCut. Copyright (C) 2011 Thomas Oster + * <thomas.oster@rwth-aachen.de> RWTH Aachen University - 52062 Aachen, Germany + * + * VisiCut is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * VisiCut is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with VisiCut. If not, see <http://www.gnu.org/licenses/>. + * + */ +package com.t_oster.liblasercut.dithering; + +/** + * + * @author Thomas Oster <thomas.oster@rwth-aachen.de> + */ +public class Grid extends DitheringAlgorithm +{ + + protected int blocksize = 10; + protected int blockdistance = 5; + + protected void doDithering() + { + long lumTotal = 0; + int pixelcount = 0; + int width = src.getWidth(); + int height = src.getHeight(); + + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + lumTotal += src.getGreyScale(x, y); + } + setProgress((100 * pixelcount++) / (2 * height)); + } + + int thresh = (int) (lumTotal / height / width); + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + if (y % (blocksize + blockdistance) <= blocksize + && x % (blocksize + blockdistance) <= blocksize + && src.getGreyScale(x, y) < thresh) + { + this.setBlack(x, y, true); + } + else + { + this.setBlack(x, y, false); + } + } + setProgress((100 * pixelcount++) / (2 * height)); + } + } +}