Skip to content

Commit

Permalink
fix: export image with original colorModel when there are no annotati…
Browse files Browse the repository at this point in the history
…ons (#125)
  • Loading branch information
moonayyur authored Jun 3, 2024
1 parent 63047dd commit 7369b60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/components/roi/ROIAnnotations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,22 @@ function ROIAnnotations({
useEffect(() => {
if (annotationsRef.current === null) return;
setSvgRef(annotationsRef);
}, [setSvgRef, svgRef]);
}, [setSvgRef, svgRef, annotations]);

const transform = usePanZoomTransform();

return (
<div style={{ width, height }}>
<svg
xmlns="http://www.w3.org/2000/svg"
style={{ transform, transformOrigin: '0px 0px' }}
viewBox={`0 0 ${width} ${height}`}
ref={annotationsRef}
>
{annotations}
</svg>
{annotations.length > 0 && (
<svg
xmlns="http://www.w3.org/2000/svg"
style={{ transform, transformOrigin: '0px 0px' }}
viewBox={`0 0 ${width} ${height}`}
ref={annotationsRef}
>
{annotations}
</svg>
)}
</div>
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/tool/ExportTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ function ExportTool() {
? (pipelined as Image)
: pipelined.convertColor(ImageColorModel.RGBA);
const toSave =
annotations === null ? recolored : annotations.copyTo(recolored);
annotations === null
? (pipelined as Image)
: annotations.copyTo(recolored);
return toSave;
}, [pipelined, svgRef]);

Expand Down

0 comments on commit 7369b60

Please sign in to comment.