07dcdc9c942e — Quintillus tip 8 months ago
#191 - Minor optimization to start location importing.  Have the PCX create a subimage directly when getting civ-colored start locations.

Not a measureable difference on my laptop.  Also realizing that the timings are more variable here than on my desktop or Core 2 Extreme laptop, probably because the clocks can vary so much as new computers spin up or down.
M src/main/java/com/civfanatics/civ3/xplatformeditor/GraphicsImport.java +5 -3
@@ 549,10 549,12 @@ public class GraphicsImport extends Thre
         {
             Color color = colors[i];
             startingLocationThread.setColor(6, color);
-            startLocGraphics[i] = startingLocationThread.getBufferedImage().getSubimage(0, 0, 128, 64);
+            startLocGraphics[i] = startingLocationThread.getCivColoredSubimage(6, color, 0, 0, 128, 64);
         }
         startingLocationThread = null;
         
+        long borderEnd = System.nanoTime();
+        
         int resourceGridHeight = (resourceThread.getBufferedImage().getHeight()/50);
         BufferedImage[] resourceGraphics = resourceThread.processSubdivisions(resourceGridHeight, 6, 0, 50, 50);
         resourceThread = null;

          
@@ 761,8 763,8 @@ public class GraphicsImport extends Thre
         long endGraphics = System.nanoTime();
         long grxTime = (endGraphics - startGraphics)/1000000;
         logger.info("It took " + grxTime + " milliseconds to import all the graphics.");
-        grxTime = (endGraphics - borderStart)/1000000;
-        logger.info(grxTime + " milliseconds of that was for borders");
+        grxTime = (borderEnd - borderStart)/1000000;
+        logger.info(grxTime + " milliseconds of that was for borders and start location");
         
 
         //Tile ownership - necessary for proper boundaries and ages of cities

          
M src/main/java/com/civfanatics/civ3/xplatformeditor/PCXImportThread.java +12 -0
@@ 159,6 159,18 @@ public class PCXImportThread extends Thr
             logger.error("Cannot set color on " + fileName + " as raw PCX data was not kept");
         }
     }
+    
+    public BufferedImage getCivColoredSubimage(int index, Color c, int x, int y, int width, int height) {
+        
+        if (keepPCX) {
+            pcx.setColor(index, c);
+            return pcx.getSubimage(x, y, width, height);
+        }
+        else {
+            logger.error("Cannot set color on " + fileName + " as raw PCX data was not kept");
+            return new BufferedImage(0, 0, BufferedImage.TYPE_4BYTE_ABGR);
+        }
+    }
 }
 
 class PCXExceptionHandler implements UncaughtExceptionHandler {