Преглед изворни кода

Changed image handling code

David Benson пре 9 година
родитељ
комит
12e6983e15
1 измењених фајлова са 3 додато и 28 уклоњено
  1. 3 28
      src/com/mxgraph/io/mxVsdxCodec.java

+ 3 - 28
src/com/mxgraph/io/mxVsdxCodec.java

@@ -30,11 +30,6 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXException;
 
 
-import com.google.appengine.api.images.Image;
-import com.google.appengine.api.images.ImagesService;
-import com.google.appengine.api.images.ImagesServiceFactory;
-import com.google.appengine.api.images.Transform;
-import com.google.appengine.api.images.ImagesService.OutputEncoding;
 import com.mxgraph.io.vsdx.Shape;
 import com.mxgraph.io.vsdx.Shape;
 import com.mxgraph.io.vsdx.ShapePageId;
 import com.mxgraph.io.vsdx.ShapePageId;
 import com.mxgraph.io.vsdx.VsdxShape;
 import com.mxgraph.io.vsdx.VsdxShape;
@@ -49,6 +44,7 @@ import com.mxgraph.model.mxCell;
 import com.mxgraph.model.mxGeometry;
 import com.mxgraph.model.mxGeometry;
 import com.mxgraph.model.mxGraphModel;
 import com.mxgraph.model.mxGraphModel;
 import com.mxgraph.model.mxIGraphModel;
 import com.mxgraph.model.mxIGraphModel;
+import com.mxgraph.online.GaeUtils;
 import com.mxgraph.online.Utils;
 import com.mxgraph.online.Utils;
 import com.mxgraph.online.mxBase64;
 import com.mxgraph.online.mxBase64;
 import com.mxgraph.util.mxConstants;
 import com.mxgraph.util.mxConstants;
@@ -164,32 +160,11 @@ public class mxVsdxCodec
 					//Some BMP images are huge and doesn't show up in the browser, so, it is better to compress it as PNG 
 					//Some BMP images are huge and doesn't show up in the browser, so, it is better to compress it as PNG 
 					if (filename.toLowerCase().endsWith(".bmp")) 
 					if (filename.toLowerCase().endsWith(".bmp")) 
 					{
 					{
-						boolean isRunningGAE; //if running under Google App Engine, ImageIO is not available 
-						try
-						{
-							Class.forName("com.google.appengine.api.images.ImagesServiceFactory");
-							isRunningGAE = true;
-						}
-						catch (Throwable t) 
-						{
-							isRunningGAE = false;
-						}
-						
 						try 
 						try 
 						{
 						{
-							if (isRunningGAE)
+							if (GaeUtils.isGae())
 							{
 							{
-								ImagesService imagesService = ImagesServiceFactory.getImagesService();
-	
-								Image image = ImagesServiceFactory.makeImage(out.toByteArray());
-	
-								//dummy transform
-								Transform transform = ImagesServiceFactory.makeCrop(0.0, 0.0, 1.0, 1.0);
-	
-								//Use PNG format as it is lossless similar to BMP but compressed
-								Image newImage = imagesService.applyTransform(transform, image, OutputEncoding.PNG);
-	
-								base64Str = StringUtils.newStringUtf8(Base64.encodeBase64(newImage.getImageData(), false));
+								base64Str = GaeUtils.convertBmp(out.toByteArray());
 							}
 							}
 							else
 							else
 							{
 							{