Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37512119
en ru br
ALT Linux repositórios
S:6.7-alt3.1

Group :: Desenvolvimento/Java
RPM: skinlf

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: skinlf-nosun-jimi-patch.patch
Download


--- src/com/l2fprod/tools/ImageUtils.java	2006-07-22 13:46:18.000000000 +1000
+++ src/com/l2fprod/tools/ImageUtils.java.new	2008-11-01 14:03:30.000000000 +1100
@@ -6,15 +6,11 @@
 
 import javax.swing.ImageIcon;
 
-import com.ibm.imageconversion.*;
-import com.sun.jimi.core.*;
-
+import javax.imageio.*;
 public class ImageUtils {
 
   public static Component bitmapCreator = new javax.swing.JLabel();
   
-  static BMPDecoder decoder = new BMPDecoder();
-  static BMPEncoder encoder = new BMPEncoder();
 
   public static Image loadPng(String pathToImage) throws Exception {
     ImageIcon icon = new ImageIcon(new File(pathToImage).toURL());
@@ -22,29 +18,34 @@
   }
 
   public static void savePng(Image image, String pathToImage) throws Exception {
-    Jimi.putImage(image, pathToImage);
+    ImageIO.write((RenderedImage)image, "png", new File(pathToImage));
   }
 
+  private static String getFileFmt(String pathToImage) throws Exception {
+    String fmt;
+    if (pathToImage.toLowerCase().endsWith(".png")) {
+      return "png";
+    }
+    if (pathToImage.toLowerCase().endsWith(".gif")) {
+      return "gif";
+    }
+    if (pathToImage.toLowerCase().endsWith(".bmp")) {
+      return "bmp";
+    }
+    return "";
+  }
+  
   public static void createPicture(String pathToImage, int index, int maxParts,
                                    String filename, boolean horizontal) {
     try {
       System.out.println("working with " + pathToImage);
       Image image = null;
 
-      if (pathToImage.toLowerCase().endsWith(".png") ||
-        	pathToImage.toLowerCase().endsWith(".gif")) {
-        image = loadPng(pathToImage);
-      } else if (pathToImage.toLowerCase().endsWith(".bmp")) {
-        decoder.setInputFilename(pathToImage);
-        decoder.triggerAction();
-        image = decoder.getResult();
-      } else {
-        throw new Error("do not know how to load " + pathToImage);
-      }
 
+      image = Toolkit.getDefaultToolkit().getImage(pathToImage);
       // if only one image, dump it as it
-	    if (index == 0 && maxParts == 1) {
-        Jimi.putImage(image, filename);
+      if (index == 0 && maxParts == 1) {
+        ImageIO.write((RenderedImage)image, getFileFmt(pathToImage), new File(pathToImage));
       } else {
         if (horizontal) {
           int partHeight = image.getHeight(bitmapCreator) / maxParts;
@@ -55,8 +56,8 @@
           image = grab(image, partWidth * index, 0,
                        partWidth, image.getHeight(bitmapCreator));
         }
-        Jimi.putImage(image, filename);
       }
+	   ImageIO.write((RenderedImage)image, getFileFmt(pathToImage), new File(pathToImage));
     } catch (Exception e) {
       System.out.println("error while working with " + pathToImage);
 	    e.printStackTrace();
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009