Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. public void LocalizePack(int requestIndex, String imageName, String Folder, String fileName) {
  2. boolean imageFound = false;
  3.  
  4.  
  5.  
  6. if(!new File(SignLink.findcachedir() + Folder + fileName + ".png").exists()) {
  7. System.out.println(SignLink.findcachedir() + Folder + fileName + ".png");
  8. /*
  9. * System.err.println("File Missing: " + fileName);
  10.  
  11. return;
  12. }
  13. try {
  14. int index = -1;
  15. int fileCount;
  16. long[] fileSizes;
  17. String[] fileNames;
  18. byte[] fileBytes = null;
  19. ZipFile zipfile = new ZipFile(SignLink.findcachedir() + "/"+ Folder + fileName + ".dat");
  20. DataInputStream datainputstream = new DataInputStream(zipfile.getInputStream(new ZipEntry(fileName + ".data")));
  21. datainputstream.readInt();
  22. fileCount = datainputstream.readInt();
  23. fileSizes = new long[fileCount];
  24. fileNames = new String[fileCount];
  25. for (int i = 0; i < fileCount; i++) {
  26. fileNames[i] = datainputstream.readUTF();
  27. fileSizes[i] = datainputstream.readLong();
  28. }
  29. for (int i = 0; i < fileNames.length; i++) {
  30. if (fileNames[i].equalsIgnoreCase(imageName + "_" + requestIndex)) {
  31. imageFound = true;
  32. index = i;
  33. break;
  34. }
  35.  
  36. }
  37. for (int i = 0; i < fileCount; i++) {
  38. fileBytes = new byte[(int) (fileSizes[i])];
  39. datainputstream.readFully(fileBytes, 0, fileBytes.length);
  40. if (i == index) {
  41. imageFound = true;
  42. datainputstream.close();
  43. break;
  44. }
  45. }*/
  46. // Image image = Toolkit.getDefaultToolkit().createImage(fileBytes);
  47. Image image = Toolkit.getDefaultToolkit().createImage(SignLink.findcachedir() + "/"+ Folder + fileName + ".png");
  48. ImageIcon sprite = new ImageIcon(image);
  49. myWidth = sprite.getIconWidth();
  50. myHeight = sprite.getIconHeight();
  51. maxWidth = myWidth;
  52. maxHeight = myHeight;
  53. drawOffsetX= 0;
  54. drawOffsetY = 0;
  55. myPixels = new int[myWidth * myHeight];
  56. PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, myWidth, myHeight, myPixels, 0, myWidth);
  57. try {
  58. pixelgrabber.grabPixels();
  59. } catch (InterruptedException e) {
  60. // TODO Auto-generated catch block
  61. e.printStackTrace();
  62. }
  63. // ColorModel cm = pixelgrabber.getColorModel();
  64. // isTrans = cm.hasAlpha();
  65. // TODO Alpha transparency
  66. image = null;
  67. setAlphaTransparency(0);
  68. // zipfile.close();
  69. if (!imageFound) {
  70.  
  71. System.out.println("IMAGE NOT FOUND:" + imageName + " index: " + requestIndex + " Restart your client, if continue and report this error to Developer");
  72.  
  73. }
  74. } //catch (Exception e) {
  75. // e.printStackTrace();
  76. // }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement