private void paint(GC gc) {
        Rectangle clientRect = getClientArea(); /* Canvas' painting area */
        if (sourceImage != null) {
            Rectangle imageRect =
                    ImageViewUtil.inverseTransformRect(transform, clientRect);
            int gap = 2; /* find a better start point to render */
            imageRect.x -= gap;
            imageRect.y -= gap;
            imageRect.width += 2 * gap;
            imageRect.height += 2 * gap;

            Rectangle imageBound = sourceImage.getBounds();
            imageRect = imageRect.intersection(imageBound);
            Rectangle destRect = ImageViewUtil.transformRect(transform, imageRect);

            gc.setBackground(getParent().getBackground());
            gc.fillRectangle(clientRect);
            gc.drawImage(
                    sourceImage,
                    imageRect.x,
                    imageRect.y,
                    imageRect.width,
                    imageRect.height,
                    destRect.x,
                    destRect.y,
                    destRect.width,
                    destRect.height);
        } else {
            gc.setClipping(clientRect);
            gc.fillRectangle(clientRect);
            initScrollBars();
        }
    }
Constructor for ScrollableCanvas.

@param parent the parent of this control.
@param style  the style of this control.
plugins/org.jkiss.dbeaver.ui.editors.image/src/org/jkiss/dbeaver/ui/controls/imageview/ImageViewCanvas.java