Skip to content

Commit

Permalink
finish removing transmission of template preview images code
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowmage45 committed Nov 20, 2014
1 parent 145adde commit d67baa4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public StructureTemplate getTemplate(String name)
return this.loadedTemplates.get(name);
}

public void addTemplateImage(String imageName, BufferedImage image, String md5)
public void addTemplateImage(String imageName, BufferedImage image)
{
this.templateImages.put(imageName, image);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -64,7 +61,6 @@ public class TemplateLoader
private Set<String> loadedStructureNames = new HashSet<String>();

private HashMap<String, BufferedImage> images = new HashMap<String, BufferedImage>();
private HashMap<String, String> imageMD5s = new HashMap<String, String>();

private TemplateLoader(){}
private static TemplateLoader instance = new TemplateLoader(){};
Expand Down Expand Up @@ -119,7 +115,6 @@ public void loadTemplates()
this.images.clear();
this.loadedStructureNames.clear();
this.images.clear();
this.imageMD5s.clear();
}

private void validateAndLoadImages()
Expand All @@ -133,7 +128,7 @@ private void validateAndLoadImages()
it.remove();
continue;
}
StructureTemplateManager.instance().addTemplateImage(name, images.get(name), imageMD5s.get(name));
StructureTemplateManager.instance().addTemplateImage(name, images.get(name));
}
}

Expand Down Expand Up @@ -167,36 +162,20 @@ private void loadStructureImage(String imageName, InputStream is)
{
try
{
MessageDigest md = MessageDigest.getInstance("MD5");
DigestInputStream dis = new DigestInputStream(is, md);//InputStream is closed externally
BufferedImage image = ImageIO.read(is);
if(image!=null && image.getWidth()==AWStructureStatics.structureImageWidth && image.getHeight()==AWStructureStatics.structureImageHeight)
{
images.put(imageName, image);
byte[] data = md.digest();
String md5 = "";
StringBuilder sb = new StringBuilder(2*data.length);
for(byte b : data)
{
sb.append(String.format("%02x", b&0xff));
}
md5 = sb.toString();
imageMD5s.put(imageName, md5);
images.put(imageName, image);
}
else
{
AWLog.logError("Attempted to load improper sized template image: "+imageName+ " with dimensions of: "+image.getWidth()+"x"+image.getHeight()+". Specified width/height is: "+AWStructureStatics.structureImageWidth+"x"+AWStructureStatics.structureImageHeight);
}
// dis.close();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
}
}

private int loadTemplatesFromZipStream(ZipInputStream zis)
Expand Down

0 comments on commit d67baa4

Please # to comment.