propane 3.3.1-java → 3.6.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -2
  3. data/.mvn/wrapper/MavenWrapperDownloader.java +117 -0
  4. data/.mvn/wrapper/maven-wrapper.properties +2 -3
  5. data/.travis.yml +9 -0
  6. data/CHANGELOG.md +17 -5
  7. data/Gemfile +2 -0
  8. data/README.md +17 -8
  9. data/Rakefile +16 -30
  10. data/bin/propane +3 -1
  11. data/lib/propane.rb +6 -4
  12. data/lib/propane/app.rb +20 -10
  13. data/lib/propane/creators/sketch_class.rb +7 -1
  14. data/lib/propane/creators/sketch_factory.rb +4 -2
  15. data/lib/propane/creators/sketch_writer.rb +1 -0
  16. data/lib/propane/helper_methods.rb +23 -24
  17. data/lib/propane/helpers/numeric.rb +2 -0
  18. data/lib/propane/helpers/version_error.rb +1 -0
  19. data/lib/propane/library.rb +5 -1
  20. data/lib/propane/library_loader.rb +2 -0
  21. data/lib/propane/native_folder.rb +21 -15
  22. data/lib/propane/native_loader.rb +3 -0
  23. data/lib/propane/runner.rb +14 -6
  24. data/lib/propane/version.rb +2 -1
  25. data/library/boids/boids.rb +21 -11
  26. data/library/color_group/color_group.rb +28 -0
  27. data/library/control_panel/control_panel.rb +8 -5
  28. data/library/dxf/dxf.rb +6 -0
  29. data/library/file_chooser/chooser.rb +10 -9
  30. data/library/file_chooser/file_chooser.rb +10 -9
  31. data/library/library_proxy/library_proxy.rb +2 -0
  32. data/library/net/net.rb +7 -0
  33. data/library/simplex_noise/simplex_noise.rb +2 -0
  34. data/library/slider/slider.rb +23 -22
  35. data/library/vector_utils/vector_utils.rb +4 -0
  36. data/library/video_event/video_event.rb +4 -1
  37. data/mvnw +127 -51
  38. data/mvnw.cmd +182 -145
  39. data/pom.rb +53 -50
  40. data/pom.xml +17 -8
  41. data/propane.gemspec +13 -11
  42. data/src/main/java/monkstone/ColorUtil.java +13 -1
  43. data/src/main/java/monkstone/MathToolModule.java +253 -203
  44. data/src/main/java/monkstone/PropaneLibrary.java +2 -2
  45. data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
  46. data/src/main/java/monkstone/filechooser/Chooser.java +2 -1
  47. data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
  48. data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
  49. data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
  50. data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
  51. data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
  52. data/src/main/java/monkstone/slider/SliderBar.java +1 -1
  53. data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
  54. data/src/main/java/monkstone/slider/WheelHandler.java +7 -6
  55. data/src/main/java/monkstone/vecmath/package-info.java +1 -1
  56. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +2 -2
  57. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
  58. data/src/main/java/monkstone/videoevent/CaptureEvent.java +27 -0
  59. data/src/main/java/monkstone/videoevent/{VideoInterface.java → MovieEvent.java} +11 -27
  60. data/src/main/java/monkstone/videoevent/package-info.java +1 -1
  61. data/src/main/java/processing/awt/PGraphicsJava2D.java +2164 -1661
  62. data/src/main/java/processing/awt/PImageAWT.java +377 -0
  63. data/src/main/java/processing/awt/PShapeJava2D.java +280 -268
  64. data/src/main/java/processing/awt/PSurfaceAWT.java +942 -829
  65. data/src/main/java/processing/awt/ShimAWT.java +581 -0
  66. data/src/main/java/processing/core/PApplet.java +831 -824
  67. data/src/main/java/processing/core/PConstants.java +477 -447
  68. data/src/main/java/processing/core/PFont.java +914 -880
  69. data/src/main/java/processing/core/PGraphics.java +229 -213
  70. data/src/main/java/processing/core/PImage.java +620 -318
  71. data/src/main/java/processing/core/PMatrix.java +172 -159
  72. data/src/main/java/processing/core/PMatrix2D.java +478 -409
  73. data/src/main/java/processing/core/PMatrix3D.java +762 -735
  74. data/src/main/java/processing/core/PShape.java +2888 -2652
  75. data/src/main/java/processing/core/PShapeOBJ.java +436 -415
  76. data/src/main/java/processing/core/PShapeSVG.java +1702 -1479
  77. data/src/main/java/processing/core/PStyle.java +40 -37
  78. data/src/main/java/processing/core/PSurface.java +139 -97
  79. data/src/main/java/processing/core/PSurfaceNone.java +296 -208
  80. data/src/main/java/processing/core/PVector.java +997 -965
  81. data/src/main/java/processing/core/ThinkDifferent.java +12 -17
  82. data/src/main/java/processing/data/DoubleDict.java +756 -710
  83. data/src/main/java/processing/data/DoubleList.java +749 -696
  84. data/src/main/java/processing/data/FloatDict.java +748 -702
  85. data/src/main/java/processing/data/FloatList.java +751 -697
  86. data/src/main/java/processing/data/IntDict.java +720 -673
  87. data/src/main/java/processing/data/IntList.java +699 -633
  88. data/src/main/java/processing/data/JSONArray.java +931 -873
  89. data/src/main/java/processing/data/JSONObject.java +1262 -1165
  90. data/src/main/java/processing/data/JSONTokener.java +351 -341
  91. data/src/main/java/processing/data/LongDict.java +710 -663
  92. data/src/main/java/processing/data/LongList.java +701 -635
  93. data/src/main/java/processing/data/Sort.java +37 -41
  94. data/src/main/java/processing/data/StringDict.java +525 -486
  95. data/src/main/java/processing/data/StringList.java +626 -580
  96. data/src/main/java/processing/data/Table.java +3690 -3510
  97. data/src/main/java/processing/data/TableRow.java +182 -183
  98. data/src/main/java/processing/data/XML.java +957 -883
  99. data/src/main/java/processing/dxf/RawDXF.java +404 -0
  100. data/src/main/java/processing/event/Event.java +87 -66
  101. data/src/main/java/processing/event/KeyEvent.java +48 -41
  102. data/src/main/java/processing/event/MouseEvent.java +88 -113
  103. data/src/main/java/processing/event/TouchEvent.java +10 -6
  104. data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
  105. data/src/main/java/processing/javafx/PSurfaceFX.java +149 -121
  106. data/src/main/java/processing/net/Client.java +744 -0
  107. data/src/main/java/processing/net/Server.java +388 -0
  108. data/src/main/java/processing/opengl/FontTexture.java +289 -270
  109. data/src/main/java/processing/opengl/FrameBuffer.java +386 -364
  110. data/src/main/java/processing/opengl/LinePath.java +547 -500
  111. data/src/main/java/processing/opengl/LineStroker.java +588 -581
  112. data/src/main/java/processing/opengl/PGL.java +3047 -2914
  113. data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
  114. data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
  115. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12378 -12075
  116. data/src/main/java/processing/opengl/PJOGL.java +1753 -1670
  117. data/src/main/java/processing/opengl/PShader.java +1266 -1257
  118. data/src/main/java/processing/opengl/PShapeOpenGL.java +4678 -4580
  119. data/src/main/java/processing/opengl/PSurfaceJOGL.java +1114 -1027
  120. data/src/main/java/processing/opengl/Texture.java +1492 -1401
  121. data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
  122. data/test/create_test.rb +21 -20
  123. data/test/deglut_spec_test.rb +4 -2
  124. data/test/helper_methods_test.rb +49 -20
  125. data/test/math_tool_test.rb +39 -32
  126. data/test/native_folder.rb +47 -0
  127. data/test/respond_to_test.rb +3 -2
  128. data/test/sketches/key_event.rb +2 -2
  129. data/test/sketches/library/my_library/my_library.rb +3 -0
  130. data/test/test_helper.rb +2 -0
  131. data/test/vecmath_spec_test.rb +35 -22
  132. data/vendors/Rakefile +33 -62
  133. metadata +54 -45
  134. data/src/main/java/processing/core/util/image/ImageLoadFacade.java +0 -161
  135. data/src/main/java/processing/core/util/image/ImageSaveFacade.java +0 -169
  136. data/src/main/java/processing/core/util/image/constants/TifConstants.java +0 -45
  137. data/src/main/java/processing/core/util/image/load/AwtImageLoadStrategy.java +0 -80
  138. data/src/main/java/processing/core/util/image/load/Base64StringImageLoadStrategy.java +0 -73
  139. data/src/main/java/processing/core/util/image/load/FallbackImageLoadStrategy.java +0 -70
  140. data/src/main/java/processing/core/util/image/load/ImageIoImageLoadStrategy.java +0 -132
  141. data/src/main/java/processing/core/util/image/load/ImageLoadStrategy.java +0 -48
  142. data/src/main/java/processing/core/util/image/load/ImageLoadUtil.java +0 -45
  143. data/src/main/java/processing/core/util/image/load/TgaImageLoadStrategy.java +0 -255
  144. data/src/main/java/processing/core/util/image/load/TiffImageLoadStrategy.java +0 -98
  145. data/src/main/java/processing/core/util/image/save/ImageSaveStrategy.java +0 -49
  146. data/src/main/java/processing/core/util/image/save/ImageSaveUtil.java +0 -48
  147. data/src/main/java/processing/core/util/image/save/ImageWriterImageSaveStrategy.java +0 -179
  148. data/src/main/java/processing/core/util/image/save/SaveImageException.java +0 -41
  149. data/src/main/java/processing/core/util/image/save/TgaImageSaveStrategy.java +0 -198
  150. data/src/main/java/processing/core/util/image/save/TiffImageSaveStrategy.java +0 -91
  151. data/src/main/java/processing/core/util/image/save/TiffNakedFilenameImageSaveStrategy.java +0 -57
  152. data/src/main/java/processing/core/util/io/InputFactory.java +0 -285
  153. data/src/main/java/processing/core/util/io/PathUtil.java +0 -109
  154. data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
  155. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
  156. data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
  157. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -1,161 +0,0 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
- /*
4
- Part of the Processing project - http://processing.org
5
-
6
- Copyright (c) 2012-18 The Processing Foundation
7
- Copyright (c) 2004-12 Ben Fry and Casey Reas
8
- Copyright (c) 2001-04 Massachusetts Institute of Technology
9
-
10
- This library is free software; you can redistribute it and/or
11
- modify it under the terms of the GNU Lesser General Public
12
- License as published by the Free Software Foundation, version 2.1.
13
-
14
- This library is distributed in the hope that it will be useful,
15
- but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- Lesser General Public License for more details.
18
-
19
- You should have received a copy of the GNU Lesser General
20
- Public License along with this library; if not, write to the
21
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
- Boston, MA 02111-1307 USA
23
- */
24
-
25
- package processing.core.util.image;
26
-
27
- import processing.core.PApplet;
28
- import processing.core.PImage;
29
- import processing.core.util.image.load.*;
30
- import processing.core.util.io.PathUtil;
31
-
32
- import java.util.HashMap;
33
- import java.util.Map;
34
- import java.util.concurrent.atomic.AtomicReference;
35
-
36
-
37
- /**
38
- * Utility for loading images either from file system or string encoding using a set of strategies.
39
- */
40
- public class ImageLoadFacade {
41
-
42
- private static final AtomicReference<ImageLoadFacade> instance = new AtomicReference<>(null);
43
-
44
- private static final String PREFIX_BASE64_STRING_IMAGE = "data:image";
45
- private static final String PREFIX_FILE_PATH = "file://";
46
-
47
- private final Map<String, ImageLoadStrategy> loadStrategies;
48
- private final ImageLoadStrategy defaultImageLoadStrategy;
49
-
50
- /**
51
- * Get a shared instance of this singleton.
52
- *
53
- * @return Shared instance of this singleton.
54
- */
55
- public static ImageLoadFacade get() {
56
- instance.compareAndSet(null, new ImageLoadFacade());
57
- return instance.get();
58
- }
59
-
60
- /**
61
- * Hidden constructor. Clients should use get().
62
- */
63
- private ImageLoadFacade() {
64
- loadStrategies = new HashMap<>();
65
-
66
- loadStrategies.put("base64", new Base64StringImageLoadStrategy());
67
-
68
- loadStrategies.put("tga", new TgaImageLoadStrategy());
69
-
70
- ImageLoadStrategy tifImageLoadStrategy = new TiffImageLoadStrategy();
71
- loadStrategies.put("tif", tifImageLoadStrategy);
72
- loadStrategies.put("tiff", tifImageLoadStrategy);
73
-
74
- ImageLoadStrategy awtImageLoadStrategy = new AwtImageLoadStrategy();
75
- defaultImageLoadStrategy = new ImageIoImageLoadStrategy();
76
-
77
- ImageLoadStrategy awtFallbackStrategy = new FallbackImageLoadStrategy(
78
- awtImageLoadStrategy,
79
- defaultImageLoadStrategy
80
- );
81
- loadStrategies.put("jpg", awtFallbackStrategy);
82
- loadStrategies.put("jpeg", awtFallbackStrategy);
83
- loadStrategies.put("gif", awtFallbackStrategy);
84
- loadStrategies.put("png", awtFallbackStrategy);
85
- loadStrategies.put("unknown", awtFallbackStrategy);
86
- }
87
-
88
- /**
89
- * Load an image embedded within an SVG string.
90
- *
91
- * @param pApplet The PApplet on whose behalf an SVG is being parsed. This must be given so that
92
- * image can be retrieved in the case of sketch relative file.
93
- * @param svgImageStr The SVG string to load which can be data:image or file://.
94
- * @return The image loaded as a PImage.
95
- */
96
- public PImage loadFromSvg(PApplet pApplet, String svgImageStr) {
97
- if (svgImageStr == null) {
98
- return null;
99
- }
100
-
101
- if (svgImageStr.startsWith(PREFIX_BASE64_STRING_IMAGE)) {
102
- String[] parts = svgImageStr.split(";base64,");
103
- String extension = parts[0].substring(11);
104
- String encodedData = parts[1];
105
- return loadStrategies.get("base64").load(pApplet, encodedData, extension);
106
- } else if (svgImageStr.startsWith(PREFIX_FILE_PATH)) {
107
- String filePath = svgImageStr.substring(PREFIX_FILE_PATH.length());
108
- return loadFromFile(pApplet, filePath);
109
- } else {
110
- return null;
111
- }
112
- }
113
-
114
- /**
115
- * Load an image from a file.
116
- *
117
- * @param pApplet The PApplet through which the image should be retrieved in the case of sketch
118
- * relative file (data folder for example).
119
- * @param path The path to the file to be opened.
120
- * @return The image loaded.
121
- */
122
- public PImage loadFromFile(PApplet pApplet, String path) {
123
- return loadFromFile(pApplet, path, null);
124
- }
125
-
126
- /**
127
- * Load an image from a file using the given file extension.
128
- *
129
- * @param pApplet The PApplet through which the image should be retrieved in the case of sketch
130
- * relative file (data folder for example).
131
- * @param path The path to the file to be opened.
132
- * @param extension The extension with which the image should be loaded like "png".
133
- * @return The image loaded.
134
- */
135
- public PImage loadFromFile(PApplet pApplet, String path, String extension) {
136
- if (extension == null) {
137
- extension = PathUtil.parseExtension(path);
138
- }
139
-
140
- // just in case. them users will try anything!
141
- extension = PathUtil.cleanExtension(extension);
142
-
143
- // Find strategy for loading
144
- ImageLoadStrategy imageLoadStrategy = loadStrategies.getOrDefault(
145
- extension,
146
- defaultImageLoadStrategy
147
- );
148
-
149
- // Load image
150
- PImage resultImage = imageLoadStrategy.load(pApplet, path, extension);
151
-
152
- // Report error or return
153
- if (resultImage == null) {
154
- System.err.println("Could not find a method to load " + path);
155
- return null;
156
- } else {
157
- return resultImage;
158
- }
159
- }
160
-
161
- }
@@ -1,169 +0,0 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
- /*
4
- Part of the Processing project - http://processing.org
5
-
6
- Copyright (c) 2012-18 The Processing Foundation
7
- Copyright (c) 2004-12 Ben Fry and Casey Reas
8
- Copyright (c) 2001-04 Massachusetts Institute of Technology
9
-
10
- This library is free software; you can redistribute it and/or
11
- modify it under the terms of the GNU Lesser General Public
12
- License as published by the Free Software Foundation, version 2.1.
13
-
14
- This library is distributed in the hope that it will be useful,
15
- but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- Lesser General Public License for more details.
18
-
19
- You should have received a copy of the GNU Lesser General
20
- Public License along with this library; if not, write to the
21
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
- Boston, MA 02111-1307 USA
23
- */
24
-
25
- package processing.core.util.image;
26
-
27
- import processing.core.PApplet;
28
- import processing.core.PGraphics;
29
- import processing.core.util.image.save.*;
30
- import processing.core.util.io.PathUtil;
31
-
32
- import java.io.File;
33
- import java.io.IOException;
34
- import java.util.HashMap;
35
- import java.util.Map;
36
- import java.util.concurrent.atomic.AtomicReference;
37
-
38
-
39
- /**
40
- * Facade to load PImages from various sources.
41
- */
42
- public class ImageSaveFacade {
43
-
44
- private static final AtomicReference<ImageSaveFacade> instance = new AtomicReference<>(null);
45
-
46
- private final Map<String, ImageSaveStrategy> saveStrategies;
47
- private final ImageSaveStrategy defaultImageSaveStrategy;
48
-
49
- /**
50
- * Get a shared instance of this singleton.
51
- *
52
- * @return Shared instance of ImageSaveFacade.
53
- */
54
- public static ImageSaveFacade get() {
55
- instance.compareAndSet(null, new ImageSaveFacade());
56
- return instance.get();
57
- }
58
-
59
- /**
60
- * Private hidden constructor requiring clients to use get().
61
- */
62
- private ImageSaveFacade() {
63
- saveStrategies = new HashMap<>();
64
-
65
- ImageSaveStrategy imageWriterImageSaveStrategy = new ImageWriterImageSaveStrategy();
66
- for (String format : javax.imageio.ImageIO.getWriterFormatNames()) {
67
- saveStrategies.put(format.toLowerCase(), imageWriterImageSaveStrategy);
68
- }
69
-
70
- ImageSaveStrategy tgaImageSaveStrategy = new TgaImageSaveStrategy();
71
- saveStrategies.put("tga", tgaImageSaveStrategy);
72
-
73
- ImageSaveStrategy tiffImageSaveStrategy = new TiffImageSaveStrategy();
74
- saveStrategies.put("tiff", tiffImageSaveStrategy);
75
-
76
- defaultImageSaveStrategy = new TiffNakedFilenameImageSaveStrategy();
77
- }
78
-
79
- /**
80
- * Save a raw representation of pixel values to a file given that file's path.
81
- *
82
- * @param pixels The raw representation of the image to save.
83
- * @param pixelWidth Width of the image in pixels.
84
- * @param pixelheight Height of the image in pixels.
85
- * @param format Format corresponding to value in PConstants like PConstants.ARGB.
86
- * @param filename The path at which the file should be saved like "test/path/output.png".
87
- */
88
- public boolean save(int[] pixels, int pixelWidth, int pixelHeight, int format, String filename) {
89
- return save(
90
- pixels,
91
- pixelWidth,
92
- pixelHeight,
93
- format,
94
- filename,
95
- null
96
- );
97
- }
98
-
99
- /**
100
- * Save a raw representation of pixel values to a file given that file's path.
101
- *
102
- * @param pixels The raw representation of the image to save.
103
- * @param pixelWidth Width of the image in pixels.
104
- * @param pixelheight Height of the image in pixels.
105
- * @param format Format corresponding to value in PConstants like PConstants.ARGB.
106
- * @param filename The path at which the file should be saved like "test/path/output.png".
107
- * @param pApplet The applet through which files should be saved when using sketch relative paths.
108
- * Can pass null if using absolute paths.
109
- */
110
- public boolean save(int[] pixels, int pixelWidth, int pixelHeight, int format, String filename,
111
- PApplet pApplet) {
112
-
113
- filename = preparePath(pApplet, filename);
114
-
115
- String extension = PathUtil.parseExtension(filename);
116
-
117
- ImageSaveStrategy imageSaveStrategy = saveStrategies.getOrDefault(
118
- extension,
119
- defaultImageSaveStrategy
120
- );
121
-
122
- try {
123
- return imageSaveStrategy.save(
124
- pixels,
125
- pixelWidth,
126
- pixelHeight,
127
- format,
128
- filename
129
- );
130
- } catch (IOException e) {
131
- System.err.println("Error while saving image.");
132
- e.printStackTrace();
133
- return false;
134
- } catch (SaveImageException e) {
135
- PGraphics.showException(e.getMessage());
136
- return false;
137
- }
138
-
139
- }
140
-
141
- /**
142
- * Ensure that the path is ready so that a file can be saved.
143
- *
144
- * @param pApplet The applet through which files should be saved when using sketch relative paths.
145
- * Can pass null if using absolute paths.
146
- * @param filename The filename that will be written and for which a path needs to be prepared.
147
- * @return Completed path useable for writing like a file path that has been made relative to
148
- * the sketch folder.
149
- */
150
- private String preparePath(PApplet pApplet, String filename) {
151
- if (pApplet != null) {
152
- return pApplet.savePath(filename);
153
- } else {
154
- File file = new File(filename);
155
- if (file.isAbsolute()) {
156
- // make sure that the intermediate folders have been created
157
- PathUtil.createPath(file);
158
- return filename;
159
- } else {
160
- String msg =
161
- "PImage.save() requires an absolute path. " +
162
- "Use createImage(), or pass savePath() to save().";
163
-
164
- throw new SaveImageException(msg);
165
- }
166
- }
167
- }
168
-
169
- }
@@ -1,45 +0,0 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
- /*
4
- Part of the Processing project - http://processing.org
5
-
6
- Copyright (c) 2012-18 The Processing Foundation
7
- Copyright (c) 2004-12 Ben Fry and Casey Reas
8
- Copyright (c) 2001-04 Massachusetts Institute of Technology
9
-
10
- This library is free software; you can redistribute it and/or
11
- modify it under the terms of the GNU Lesser General Public
12
- License as published by the Free Software Foundation, version 2.1.
13
-
14
- This library is distributed in the hope that it will be useful,
15
- but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- Lesser General Public License for more details.
18
-
19
- You should have received a copy of the GNU Lesser General
20
- Public License along with this library; if not, write to the
21
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
- Boston, MA 02111-1307 USA
23
- */
24
-
25
- package processing.core.util.image.constants;
26
-
27
-
28
- /**
29
- * Constants to use for tif images.
30
- */
31
- public class TifConstants {
32
-
33
- public static final byte TIFF_HEADER[] = {
34
- 77, 77, 0, 42, 0, 0, 0, 8, 0, 9, 0, -2, 0, 4, 0, 0, 0, 1, 0, 0,
35
- 0, 0, 1, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 3, 0, 0, 0, 1,
36
- 0, 0, 0, 0, 1, 2, 0, 3, 0, 0, 0, 3, 0, 0, 0, 122, 1, 6, 0, 3, 0,
37
- 0, 0, 1, 0, 2, 0, 0, 1, 17, 0, 4, 0, 0, 0, 1, 0, 0, 3, 0, 1, 21,
38
- 0, 3, 0, 0, 0, 1, 0, 3, 0, 0, 1, 22, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0,
39
- 1, 23, 0, 4, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 8, 0, 8
40
- };
41
-
42
- public static final String TIFF_ERROR =
43
- "Error: Processing can only read its own TIFF files.";
44
-
45
- }
@@ -1,80 +0,0 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
- /*
4
- Part of the Processing project - http://processing.org
5
-
6
- Copyright (c) 2012-18 The Processing Foundation
7
- Copyright (c) 2004-12 Ben Fry and Casey Reas
8
- Copyright (c) 2001-04 Massachusetts Institute of Technology
9
-
10
- This library is free software; you can redistribute it and/or
11
- modify it under the terms of the GNU Lesser General Public
12
- License as published by the Free Software Foundation, version 2.1.
13
-
14
- This library is distributed in the hope that it will be useful,
15
- but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- Lesser General Public License for more details.
18
-
19
- You should have received a copy of the GNU Lesser General
20
- Public License along with this library; if not, write to the
21
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
- Boston, MA 02111-1307 USA
23
- */
24
-
25
- package processing.core.util.image.load;
26
-
27
- import processing.core.PApplet;
28
- import processing.core.PImage;
29
-
30
- import javax.swing.*;
31
- import java.awt.*;
32
- import java.awt.color.ColorSpace;
33
- import java.awt.image.BufferedImage;
34
-
35
-
36
- /**
37
- * Strategy to load an image through ImageIcon / abstract window toolkit.
38
- */
39
- public class AwtImageLoadStrategy implements ImageLoadStrategy {
40
-
41
- @Override
42
- public PImage load(PApplet pApplet, String path, String extension) {
43
- byte bytes[] = pApplet.loadBytes(path);
44
- if (bytes == null) {
45
- return null;
46
- } else {
47
- //Image awtImage = Toolkit.getDefaultToolkit().createImage(bytes);
48
- Image awtImage = new ImageIcon(bytes).getImage();
49
-
50
- if (awtImage instanceof BufferedImage) {
51
- BufferedImage buffImage = (BufferedImage) awtImage;
52
- int space = buffImage.getColorModel().getColorSpace().getType();
53
- if (space == ColorSpace.TYPE_CMYK) {
54
- System.err.println(path + " is a CMYK image, " +
55
- "only RGB images are supported.");
56
- return null;
57
- /*
58
- // wishful thinking, appears to not be supported
59
- // https://community.oracle.com/thread/1272045?start=0&tstart=0
60
- BufferedImage destImage =
61
- new BufferedImage(buffImage.getWidth(),
62
- buffImage.getHeight(),
63
- BufferedImage.TYPE_3BYTE_BGR);
64
- ColorConvertOp op = new ColorConvertOp(null);
65
- op.filter(buffImage, destImage);
66
- image = new PImage(destImage);
67
- */
68
- }
69
- }
70
-
71
- boolean checkAlpha = extension.equalsIgnoreCase("gif")
72
- || extension.equalsIgnoreCase("png")
73
- || extension.equalsIgnoreCase("unknown");
74
-
75
- PImage image = new PImage(awtImage, checkAlpha, pApplet);
76
- return image;
77
- }
78
- }
79
-
80
- }