Author: amarkhel
Date: 2009-02-03 07:45:27 -0500 (Tue, 03 Feb 2009)
New Revision: 12539
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/modalpanel/test.java
Log:
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/modalpanel/test.java
===================================================================
---
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/modalpanel/test.java 2009-02-03
12:26:30 UTC (rev 12538)
+++
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/modalpanel/test.java 2009-02-03
12:45:27 UTC (rev 12539)
@@ -10,9 +10,14 @@
import java.util.Map;
import javax.imageio.ImageIO;
+import javax.imageio.stream.FileImageInputStream;
+import org.richfaces.model.UploadItem;
import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.service.Constants;
+import org.richfaces.realworld.util.ImageUtils;
+import org.richfaces.realworld.util.ImageUtils.ImageDimension;
public class test {
@@ -21,11 +26,12 @@
* @throws IOException
*/
public static void main(String[] args) throws IOException {
- String directory ="C:\\Documents and Settings\\Administrator\\Desktop\\Fun";
- writeFiles(directory, "_mini", 100, 100);
+ String directory ="C:\\Documents and
Settings\\Administrator\\Desktop\\amarkhel\\Sport";
+ writeFiles(directory, "_mini", 150);
+ writeFiles(directory, "_medium", 600);
}
- public static void renameAllImagesFromAlbumAndChilds(Album album, String replace,
+ /*public static void renameAllImagesFromAlbumAndChilds(Album album, String replace,
String forReplace) {
for(Image image: album.getImages()){
System.out.println(image.getPath());
@@ -37,15 +43,12 @@
String forReplace2 = forReplace + "/" + a.getName();
renameAllImagesFromAlbumAndChilds(a, replace2, forReplace2);
}
- }
+ }*/
- private static void writeFiles(String directory, String pattern, int width, int height)
{
+ private static void writeFiles(String directory, String pattern, int size) {
File f = new File(directory);
for(String s: f.list()){
File temp = new File(directory +"\\"+ s);
- if(temp.isDirectory() && !(directory +"\\"+
s).endsWith("avatars")){
- writeFiles(directory +"\\"+ s,pattern, width, height);
- }
if(s.endsWith(".jpg") &&
!s.endsWith("_mini.jpg")&& !s.endsWith("_medium.jpg")){
BufferedImage bsrc =null;
try {
@@ -54,15 +57,18 @@
// TODO Auto-generated catch block
e1.printStackTrace();
}
+ int i = bsrc.getWidth() > bsrc.getHeight()? bsrc.getWidth(): bsrc.getHeight();
+ int width2 = bsrc.getWidth();
+ double d = (double) size
+ / i;
+ Double yy = ((Double)d*bsrc.getWidth());
+ int width = yy.intValue();
+ yy = ((Double)d*bsrc.getHeight());
+ int height= yy.intValue();
BufferedImage bdest = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = bdest.createGraphics();
- int width2 = bsrc.getWidth();
- int height2 = bsrc.getHeight();
- double d = (double) width
- / width2;
- double e = (double) height / height2;
- AffineTransform at = AffineTransform.getScaleInstance(d, e);
+ AffineTransform at = AffineTransform.getScaleInstance(d, d);
Map<RenderingHints.Key, Object> hints = new HashMap<RenderingHints.Key,
Object>();
hints.put(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.addRenderingHints(hints);
Show replies by date