Skip to content

Commit fdad379

Browse files
c298leebillyvg
andauthored
feat(feedback): Improve screenshot quality for retina displays (#12487)
Improves screenshot quality after cropping for retina displays. This increases resolution after cropping by factoring in DPI. Before: <img width="974" alt="image" src="https://github.com/getsentry/sentry-javascript/assets/55311782/e39397ae-8c6c-47a6-8d10-260c16eb8234"> After: <img width="974" alt="image" src="https://github.com/getsentry/sentry-javascript/assets/55311782/bd05b88b-3d2f-4193-b55b-75aae0bba8b9"> The size is the same when cropping but when viewing feedbacks, screenshots from retina displays are twice as large due to higher DPI. Closes #12329 --------- Co-authored-by: Billy Vong <billyvg@users.noreply.github.com>
1 parent 62be087 commit fdad379

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/feedback/src/screenshot/components/ScreenshotEditor.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ export function makeScreenshotEditorComponent({ imageBuffer, dialog, options }:
187187
const cutoutCanvas = DOCUMENT.createElement('canvas');
188188
const imageBox = constructRect(getContainedSize(imageBuffer));
189189
const croppingBox = constructRect(croppingRect);
190-
cutoutCanvas.width = croppingBox.width;
191-
cutoutCanvas.height = croppingBox.height;
190+
cutoutCanvas.width = croppingBox.width * DPI;
191+
cutoutCanvas.height = croppingBox.height * DPI;
192192

193193
const cutoutCtx = cutoutCanvas.getContext('2d');
194194
if (cutoutCtx && imageBuffer) {
@@ -200,8 +200,8 @@ export function makeScreenshotEditorComponent({ imageBuffer, dialog, options }:
200200
(croppingBox.height / imageBox.height) * imageBuffer.height,
201201
0,
202202
0,
203-
croppingBox.width,
204-
croppingBox.height,
203+
cutoutCanvas.width,
204+
cutoutCanvas.height,
205205
);
206206
}
207207

@@ -210,8 +210,8 @@ export function makeScreenshotEditorComponent({ imageBuffer, dialog, options }:
210210
ctx.clearRect(0, 0, imageBuffer.width, imageBuffer.height);
211211
imageBuffer.width = cutoutCanvas.width;
212212
imageBuffer.height = cutoutCanvas.height;
213-
imageBuffer.style.width = `${cutoutCanvas.width}px`;
214-
imageBuffer.style.height = `${cutoutCanvas.height}px`;
213+
imageBuffer.style.width = `${croppingBox.width}px`;
214+
imageBuffer.style.height = `${croppingBox.height}px`;
215215
ctx.drawImage(cutoutCanvas, 0, 0);
216216
resizeCropper();
217217
}

0 commit comments

Comments
 (0)