Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/base/src/mainview/mainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import { Circle, Fill, Stroke, Style } from 'ol/style';
import { singleClick } from 'ol/events/condition';
import TileSource from 'ol/source/Tile';
import { FeatureLike } from 'ol/Feature';
import ImageSource from 'ol/source/Image';

interface IProps {
viewModel: MainViewModel;
Expand Down Expand Up @@ -1127,6 +1128,21 @@ export class MainView extends React.Component<IProps, IStates> {
const state = layer.getSourceState();
if (state === 'ready') {
layer.un('change', checkState);

// Apply image smoothing logic for image layers only
const source = layer.getSource();
if (source && source instanceof ImageSource) {
layer.on('prerender', event => {
const context = event.context;
if (context && context.canvas) {
const canvasContext = context.canvas.getContext('2d');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 so there is no official OpenLayers API to disable image smoothing? Do we really need to get our hands dirty and manipulate the canvas context?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on what I read, there was a way before with OpenLayers to set the imageSmoothing: false but I guess it's not available anymore with the current version. If someone has another way to do it, I'm open for suggestions!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's unfortunate :S

Let's get this PR in, we can always revisit it later if we have a better solution for this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting interpolate: false when adding Image Layers here should accomplish the same thing.

interpolatefalse

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah great! Thanks for looking into it

if (canvasContext) {
canvasContext.imageSmoothingEnabled = false;
}
}
});
}

resolve();
} else if (state === 'error') {
layer.un('change', checkState);
Expand Down
Loading