Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void LocalizePack(int requestIndex, String imageName, String Folder, String fileName) {
- boolean imageFound = false;
- if(!new File(SignLink.findcachedir() + Folder + fileName + ".png").exists()) {
- System.out.println(SignLink.findcachedir() + Folder + fileName + ".png");
- /*
- * System.err.println("File Missing: " + fileName);
- return;
- }
- try {
- int index = -1;
- int fileCount;
- long[] fileSizes;
- String[] fileNames;
- byte[] fileBytes = null;
- ZipFile zipfile = new ZipFile(SignLink.findcachedir() + "/"+ Folder + fileName + ".dat");
- DataInputStream datainputstream = new DataInputStream(zipfile.getInputStream(new ZipEntry(fileName + ".data")));
- datainputstream.readInt();
- fileCount = datainputstream.readInt();
- fileSizes = new long[fileCount];
- fileNames = new String[fileCount];
- for (int i = 0; i < fileCount; i++) {
- fileNames[i] = datainputstream.readUTF();
- fileSizes[i] = datainputstream.readLong();
- }
- for (int i = 0; i < fileNames.length; i++) {
- if (fileNames[i].equalsIgnoreCase(imageName + "_" + requestIndex)) {
- imageFound = true;
- index = i;
- break;
- }
- }
- for (int i = 0; i < fileCount; i++) {
- fileBytes = new byte[(int) (fileSizes[i])];
- datainputstream.readFully(fileBytes, 0, fileBytes.length);
- if (i == index) {
- imageFound = true;
- datainputstream.close();
- break;
- }
- }*/
- // Image image = Toolkit.getDefaultToolkit().createImage(fileBytes);
- Image image = Toolkit.getDefaultToolkit().createImage(SignLink.findcachedir() + "/"+ Folder + fileName + ".png");
- ImageIcon sprite = new ImageIcon(image);
- myWidth = sprite.getIconWidth();
- myHeight = sprite.getIconHeight();
- maxWidth = myWidth;
- maxHeight = myHeight;
- drawOffsetX= 0;
- drawOffsetY = 0;
- myPixels = new int[myWidth * myHeight];
- PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, myWidth, myHeight, myPixels, 0, myWidth);
- try {
- pixelgrabber.grabPixels();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- // ColorModel cm = pixelgrabber.getColorModel();
- // isTrans = cm.hasAlpha();
- // TODO Alpha transparency
- image = null;
- setAlphaTransparency(0);
- // zipfile.close();
- if (!imageFound) {
- System.out.println("IMAGE NOT FOUND:" + imageName + " index: " + requestIndex + " Restart your client, if continue and report this error to Developer");
- }
- } //catch (Exception e) {
- // e.printStackTrace();
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement