SHARE
TWEET

Untitled

a guest Feb 12th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   public DisplayImage(boolean resize, boolean mapCountries) throws IOException {
  2.     super("Province Map");
  3.     File mapProvinceFile = new File("map\\provinces.png");
  4.     BufferedImage mapProvinceImage = ImageIO.read(mapProvinceFile);
  5.     System.out.println("IMPORTANT: " + mapProvinceImage.getType());
  6.    
  7.     int[] iArray = null;
  8.     int[] pixels = mapProvinceImage.getRaster().getPixels(0, 0, mapProvinceImage.getWidth(), mapProvinceImage.getHeight(), iArray);
  9.    
  10.     long pixelTotalValue = 0;
  11.         for (int i = 0; i < 50; i++) {
  12.             for (int p = 0; p < pixels.length; p = p + 3) {
  13.               if (mapCountries) {
  14.                if (Victoria2Stats.provinceDefinitionArray.get(i).red == pixels[p]) {
  15.                    if (Victoria2Stats.provinceDefinitionArray.get(i).green == pixels[p+1]) {
  16.                        if (Victoria2Stats.provinceDefinitionArray.get(i).blue == pixels[p+2]) {
  17.                            pixels[p] = Victoria2Stats.provinceDataTable[i].ownerColor.getRed();
  18.                            pixels[p+1] = Victoria2Stats.provinceDataTable[i].ownerColor.getGreen();
  19.                            pixels[p+2] = Victoria2Stats.provinceDataTable[i].ownerColor.getBlue();
  20.                        }
  21.                    }
  22.                }
  23.               }
  24.                //pixelTotalValue = pixelTotalValue + pixels[p];
  25.                //pixelTotalValue = pixelTotalValue + pixels[p+1];
  26.                //pixelTotalValue = pixelTotalValue + pixels[p+2];
  27.           }
  28.         }
  29.    
  30.     //System.out.println("Pixel Total Value: " + pixelTotalValue);
  31.    
  32.    MemoryImageSource source = new MemoryImageSource(mapProvinceImage.getWidth(),mapProvinceImage.getHeight(),pixels,0,mapProvinceImage.getWidth());
  33.     Image imageto = createImage(source);
  34.  
  35.     //mapProvinceImage = ImageUtils.verticalflip(mapProvinceImage);
  36.     ImageIcon ii = new ImageIcon(imageto);
  37.     JScrollPane jsp = new JScrollPane(new JLabel(ii));
  38.     getContentPane().add(jsp);
  39.     setSize(800, 600);
  40.     setVisible(true);
  41.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top