in reply to Image dimensions don't match window size

I think the window size you pass to the javascript should be slightly larger than your image size because the (*)Windows manager has to draw the borders and title bars etc within the window size you specified. And therefore the client area for drawing the image is always smaller than the size you specified.

  • Comment on Re: Image dimensions don't match window size

Replies are listed 'Best First'.
Re: (2) Image dimensions don't match window size
by pg (Canon) on Dec 16, 2003 at 04:31 UTC

    Even within the client area, the browser leaves margins around the picture. Both the left margin and top margin take away spaces. To make it looks nice, you probably want to add bottom margin and right margin, so that the picture is centered.

    As the sizes of the title bar, borders and margins are fixed, so it is very easy for you to calculate window sizes in your javascript:

    window_width = 2 * BORDER_SIZE + 2 * LEFT_MARGIN

    window_height = TITLE_BAR_HEIGHT + BORDER_SIZE + 2 * TOP_MARGIN