Atlaslog
Atlaslog / Examples / Cesium / Imagery Layers Manipulation
Cesium · Runnable Example

Imagery Layers Manipulation

Runnable Cesium example: Imagery Layers Manipulation. Open the live demo, read the complete source, and copy the file into your project. No build step or API key.

Open standalone → Chinese notes All Cesium examples
/demos/cesium-imagery-layers-manipulation.htmlLIVE
single HTML file · CDN dependencies onlyinterface may contain Chinese labels

Source

demos/cesium-imagery-layers-manipulation.html
<!--
  示例:影像色彩调整
  说明:同一张底图复制四份,分别调亮度、对比度、色相与饱和度,并排对比
  核心逻辑:layer.brightness / contrast / hue / saturation / gamma → 四个相邻矩形
  依赖:CesiumJS 1.121 · jsDelivr CDN
-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta name="robots" content="noindex,follow">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>影像色彩调整</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/cesium@1.121.0/Build/Cesium/Widgets/widgets.css">
<style>
  html,body{height:100%;margin:0}
  body{background:#0e1116;color:#e6e8ec;overflow:hidden;
       font:13px/1.6 -apple-system,"Segoe UI","PingFang SC",sans-serif}
  #c{height:100%}
  .tip{position:absolute;left:12px;top:12px;z-index:5;
       background:rgba(23,28,35,.9);border:1px solid #2a313b;border-radius:6px;
       padding:8px 12px;font-size:12px;color:#a2a9b6;max-width:320px;line-height:1.6}

  .cesium-viewer-bottom .cesium-widget-credits,.cesium-viewer-animationContainer,
  .cesium-viewer-timelineContainer{display:none!important}
</style>
</head>
<body>
<div id="c"></div>
<div class="tip">四块影像来自同一张图,只是色彩参数不同:左下原图、右下高对比。</div>
<script src="https://cdn.jsdelivr.net/npm/cesium@1.121.0/Build/Cesium/Cesium.js"></script>
<script>
(function () {
  'use strict';

  var viewer = new Cesium.Viewer('c', {
    baseLayer: false,
    baseLayerPicker: false, geocoder: false, homeButton: false,
    sceneModePicker: false, navigationHelpButton: false,
    animation: false, timeline: false, fullscreenButton: false,
    infoBox: false, selectionIndicator: false
  });

  var scene = viewer.scene;
  scene.globe.baseColor = Cesium.Color.fromCssColorString('#1c2733');
  scene.backgroundColor = Cesium.Color.fromCssColorString('#0e1116');
  scene.skyBox.show = false;
  scene.sun.show = false;
  scene.moon.show = false;
  if (scene.skyAtmosphere) scene.skyAtmosphere.show = false;

  function makeImage() {
    var c = document.createElement('canvas');
    c.width = 512; c.height = 512;
    var ctx = c.getContext('2d');
    var g = ctx.createLinearGradient(0, 0, 512, 512);
    g.addColorStop(0, '#25405c');
    g.addColorStop(0.5, '#3f6b7d');
    g.addColorStop(1, '#7d9a86');
    ctx.fillStyle = g; ctx.fillRect(0, 0, 512, 512);
    ctx.fillStyle = 'rgba(230,200,140,0.55)';
    for (var i = 0; i < 60; i++) {
      ctx.fillRect((i * 83) % 480, (i * 47) % 480, 26, 26);
    }
    return c.toDataURL('image/png');
  }

  var url = makeImage();
  var cols = 4, lon0 = 115.6, lat0 = 39.4, dLon = 0.42, dLat = 0.62;
  var tweaks = [
    null,
    { brightness: 1.65 },
    { contrast: 2.2, saturation: 1.8 },
    { hue: 0.55, gamma: 0.6 }
  ];

  for (var i = 0; i < cols; i++) {
    var layer = viewer.imageryLayers.addImageryProvider(
      new Cesium.SingleTileImageryProvider({
        url: url,
        rectangle: Cesium.Rectangle.fromDegrees(lon0 + i * dLon, lat0, lon0 + (i + 1) * dLon, lat0 + dLat)
      })
    );
    var t = tweaks[i];
    if (!t) continue;
    for (var k in t) { layer[k] = t[k]; }
  }
  viewer.camera.flyTo({
    destination: Cesium.Cartesian3.fromDegrees(116.42, 39.3, 210000),
    orientation: { heading: 0, pitch: Cesium.Math.toRadians(-62), roll: 0 },
    duration: 0
  });
})();
</script>
</body>
</html>
Language: the code and this page are in English; the full tutorial and API notes for this example are in Chinese. The demo itself is the authoritative version — it runs exactly as shown.

More Cesium examples

Cesium · EXAMPLEImagery Layers Split Cesium · EXAMPLEImagery Layers Texture Filters Cesium · EXAMPLEInterpolation