Merge pull request #11378 from mike-000/patch-7
Fix imageSmoothing: false when ImageStatic is stretched to fit extent
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
@@ -0,0 +1,29 @@
|
|||||||
|
import ImageLayer from '../../../src/ol/layer/Image.js';
|
||||||
|
import Map from '../../../src/ol/Map.js';
|
||||||
|
import Static from '../../../src/ol/source/ImageStatic.js';
|
||||||
|
import View from '../../../src/ol/View.js';
|
||||||
|
|
||||||
|
const source = new Static({
|
||||||
|
url: '/data/tiles/osm/5/5/12.png',
|
||||||
|
imageExtent: [-123, 37, -122, 38],
|
||||||
|
imageSmoothing: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
new Map({
|
||||||
|
pixelRatio: 1,
|
||||||
|
target: 'map',
|
||||||
|
layers: [
|
||||||
|
new ImageLayer({
|
||||||
|
source: source,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
view: new View({
|
||||||
|
center: [-122.39, 37.81],
|
||||||
|
zoom: 12,
|
||||||
|
projection: 'EPSG:4326',
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
render({
|
||||||
|
tolerance: 0.001,
|
||||||
|
});
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
+1
-1
@@ -19,7 +19,7 @@ new Map({
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
view: new View({
|
view: new View({
|
||||||
center: fromLonLat([-122.416667, 37.783333]),
|
center: fromLonLat([-122.39, 37.81]),
|
||||||
zoom: 12,
|
zoom: 12,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
@@ -0,0 +1,30 @@
|
|||||||
|
import ImageLayer from '../../../src/ol/layer/Image.js';
|
||||||
|
import Map from '../../../src/ol/Map.js';
|
||||||
|
import Static from '../../../src/ol/source/ImageStatic.js';
|
||||||
|
import View from '../../../src/ol/View.js';
|
||||||
|
import {fromLonLat} from '../../../src/ol/proj.js';
|
||||||
|
|
||||||
|
const source = new Static({
|
||||||
|
url: '/data/tiles/osm/5/5/12.png',
|
||||||
|
imageExtent: [-123, 37, -122, 38],
|
||||||
|
imageSmoothing: false,
|
||||||
|
projection: 'EPSG:4326',
|
||||||
|
});
|
||||||
|
|
||||||
|
new Map({
|
||||||
|
pixelRatio: 1,
|
||||||
|
target: 'map',
|
||||||
|
layers: [
|
||||||
|
new ImageLayer({
|
||||||
|
source: source,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
view: new View({
|
||||||
|
center: fromLonLat([-122.39, 37.81]),
|
||||||
|
zoom: 12,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
render({
|
||||||
|
tolerance: 0.001,
|
||||||
|
});
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
+1
-1
@@ -20,7 +20,7 @@ new Map({
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
view: new View({
|
view: new View({
|
||||||
center: [-122.416667, 37.783333],
|
center: [-122.39, 37.81],
|
||||||
zoom: 12,
|
zoom: 12,
|
||||||
projection: 'EPSG:4326',
|
projection: 'EPSG:4326',
|
||||||
}),
|
}),
|
||||||
@@ -6,6 +6,7 @@ import EventType from '../events/EventType.js';
|
|||||||
import ImageSource, {defaultImageLoadFunction} from './Image.js';
|
import ImageSource, {defaultImageLoadFunction} from './Image.js';
|
||||||
import ImageState from '../ImageState.js';
|
import ImageState from '../ImageState.js';
|
||||||
import ImageWrapper from '../Image.js';
|
import ImageWrapper from '../Image.js';
|
||||||
|
import {assign} from '../obj.js';
|
||||||
import {createCanvasContext2D} from '../dom.js';
|
import {createCanvasContext2D} from '../dom.js';
|
||||||
import {getHeight, getWidth, intersects} from '../extent.js';
|
import {getHeight, getWidth, intersects} from '../extent.js';
|
||||||
import {get as getProjection} from '../proj.js';
|
import {get as getProjection} from '../proj.js';
|
||||||
@@ -138,6 +139,7 @@ class Static extends ImageSource {
|
|||||||
const targetWidth = Math.ceil(getWidth(imageExtent) / resolution);
|
const targetWidth = Math.ceil(getWidth(imageExtent) / resolution);
|
||||||
if (targetWidth != imageWidth) {
|
if (targetWidth != imageWidth) {
|
||||||
const context = createCanvasContext2D(targetWidth, imageHeight);
|
const context = createCanvasContext2D(targetWidth, imageHeight);
|
||||||
|
assign(context, this.getContextOptions());
|
||||||
const canvas = context.canvas;
|
const canvas = context.canvas;
|
||||||
context.drawImage(
|
context.drawImage(
|
||||||
image,
|
image,
|
||||||
|
|||||||
Reference in New Issue
Block a user