Changeset 10698 for extensions/jiwigo-ws-api/src
- Timestamp:
- Apr 30, 2011, 1:37:01 PM (13 years ago)
- Location:
- extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/SessionManager.java
r10505 r10698 2 2 3 3 import java.io.IOException; 4 import java.io.InputStream; 4 5 import java.io.UnsupportedEncodingException; 5 6 … … 119 120 */ 120 121 public boolean isProxyError(); 122 123 /** 124 * @param url 125 * @return 126 * @throws Exception 127 */ 128 public InputStream getInputStreamFromUrl(String url) throws Exception; 121 129 } -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/session/impl/SessionManagerImpl.java
r10505 r10698 17 17 import org.apache.http.client.ClientProtocolException; 18 18 import org.apache.http.client.entity.UrlEncodedFormEntity; 19 import org.apache.http.client.methods.HttpGet; 19 20 import org.apache.http.client.methods.HttpPost; 20 21 import org.apache.http.conn.params.ConnRoutePNames; … … 253 254 } 254 255 256 public InputStream getInputStreamFromUrl(String url) throws Exception { 257 InputStream content = null; 258 HttpGet httpGet = new HttpGet(url); 259 HttpResponse response = client.execute(httpGet); 260 content = response.getEntity().getContent(); 261 return content; 262 } 263 255 264 /** 256 265 * @return the login -
extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/transverse/util/ImagesUtil.java
r9893 r10698 51 51 .getLog(ImagesUtil.class); 52 52 53 private static final GraphicsConfiguration CONFIGURATION = GraphicsEnvironment.getLocalGraphicsEnvironment() 54 .getDefaultScreenDevice().getDefaultConfiguration(); 55 56 public static void main(String[] args) throws IOException { 57 scale("/home/mael/Bureau/test.png", "test4.jpg", 1999, 1999); 58 } 59 53 60 /** 54 61 * rotates an image … … 101 108 */ 102 109 public static boolean scale(String filePath, String tempName, int width, int height) throws IOException { 103 File file = new File(filePath);104 110 InputStream imageStream = new BufferedInputStream(new FileInputStream(filePath)); 105 111 Image image = (Image) ImageIO.read(imageStream); … … 117 123 width = (int) (height * imageRatio); 118 124 } 119 BufferedImage thumbImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 125 // BufferedImage thumbImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 126 BufferedImage thumbImage = createCompatibleImage(ImageIO.read(new File(filePath)), width, height); 120 127 Graphics2D graphics2D = thumbImage.createGraphics(); 121 128 graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); 122 129 graphics2D.drawImage(image, 0, 0, width, height, null); 123 130 graphics2D.dispose(); 124 131 // ImageIO.write(thumbImage, "jpg", new FileOutputStream(System.getProperty("java.io.tmpdir") + "/" + tempName)); 125 132 saveImage(System.getProperty("java.io.tmpdir") + "/" + tempName, thumbImage); 126 133 return true; 127 134 135 } 136 137 public static BufferedImage createCompatibleImage(BufferedImage image, int width, int height) { 138 return CONFIGURATION.createCompatibleImage(width, height, image.getTransparency()); 128 139 } 129 140
Note: See TracChangeset
for help on using the changeset viewer.