Advertisement
Guest User

SkinConverterV3

a guest
Jan 20th, 2014
2,245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.42 KB | None | 0 0
  1. package converter;
  2.  
  3. import java.awt.Graphics;
  4. import java.awt.image.BufferedImage;
  5. import javax.imageio.*;
  6. import java.io.*;
  7. import javax.swing.JOptionPane;
  8.  
  9. public class Main
  10. {
  11.     public static void main(String[] args)
  12.     {
  13.         if(args.length == 0)
  14.         {
  15.             JOptionPane.showMessageDialog(null, "This program requires atleast 1 argument.\nArguments should be the path to your skin file." , "Skin Converter by DarkVamprism" , JOptionPane.INFORMATION_MESSAGE);
  16.         }
  17.         else
  18.         {
  19.             for(String filename : args)
  20.             {
  21.                 try
  22.                 {
  23.                     BufferedImage inImg = ImageIO.read(new File(filename));
  24.                     BufferedImage outImg = new BufferedImage(64,64,BufferedImage.TYPE_INT_ARGB);
  25.                     Graphics outGfx = outImg.getGraphics();
  26.                    
  27.                     if(inImg.getHeight() == 32 && inImg.getWidth() == 64)
  28.                     {
  29.                         // Copy old layout(for the body, head and right limbs)
  30.                         outGfx.drawImage(inImg, 0, 0, 64, 32, 0, 0, 64, 32, null);
  31.                        
  32.                         // Right leg -> left leg
  33.                         outGfx.drawImage(inImg, 24, 48, 20, 52, 4, 16, 8, 20, null); // Top
  34.                         outGfx.drawImage(inImg, 28, 48, 24, 52, 8, 16, 12, 20, null); // Bottom
  35.                         outGfx.drawImage(inImg, 20, 52, 16, 64, 8, 20, 12, 32, null); // Outside -> inside
  36.                         outGfx.drawImage(inImg, 24, 52, 20, 64, 4, 20, 8, 32, null); // Front
  37.                         outGfx.drawImage(inImg, 28, 52, 24, 64, 0, 20, 4, 32, null); // Inside -> outside
  38.                         outGfx.drawImage(inImg, 32, 52, 28, 64, 12, 20, 16, 32, null); // Back
  39.  
  40.                         // Right arm -> left arm
  41.                         outGfx.drawImage(inImg, 40, 48, 36, 52, 44, 16, 48, 20, null); // Top
  42.                         outGfx.drawImage(inImg, 44, 48, 40, 52, 48, 16, 52, 20, null); // Bottom
  43.                         outGfx.drawImage(inImg, 36, 52, 32, 64, 48, 20, 52, 32, null); // Outside -> inside
  44.                         outGfx.drawImage(inImg, 40, 52, 36, 64, 44, 20, 48, 32, null); // Front
  45.                         outGfx.drawImage(inImg, 44, 52, 40, 64, 40, 20, 44, 32, null); // Inside -> outside
  46.                         outGfx.drawImage(inImg, 48, 52, 44, 64, 52, 20, 56, 32, null); // Back
  47.                        
  48.                         ImageIO.write(outImg, "png", new File(filename.substring(0,filename.length()-4) + "_converted.png"));
  49.                     }
  50.                 }
  51.                 catch(IOException e)
  52.                 {
  53.                     e.printStackTrace();
  54.                 }
  55.             }
  56.            
  57.             String msg = "Thank you for using this converter made by DarkVamprism.\n";
  58.             JOptionPane.showMessageDialog(null, msg, "Skin Converter by DarkVamprism", JOptionPane.INFORMATION_MESSAGE);
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement