Esempio n. 1
0
    public static ColorMap ColorMapForSatelliteImage(MapData mapData)
    {
        SatelliteImage satelliteImage = SatelliteImageService.getSatelliteImage();
        double         scale          = satelliteImage.getScale();

        int textureWidth  = (int)(mapData.GetWidth() * scale);
        int textureHeight = (int)(mapData.GetHeight() * scale);

        Color[] colorArray = new Color[textureWidth * textureHeight];
        if (!satelliteImage.hasSatelliteImage())
        {
            return(new ColorMap(colorArray, textureWidth, textureHeight));
        }

        MapDataSlice slice = mapData.AsSlice();

        for (int y = 0; y < textureHeight; y++)
        {
            int sliceY   = (int)(slice.GetY() * scale);
            int flippedY = satelliteImage.texture.height - (int)(sliceY + y) - 1;
            Array.ConstrainedCopy(satelliteImage.texture.GetPixels((int)(slice.GetX() * scale), flippedY, textureWidth, 1), 0, colorArray, (y * textureWidth), textureWidth);
        }

        return(new ColorMap(colorArray, textureWidth, textureHeight));
    }