Compute the window dimensions
Listing 3 computes the window dimensions based on the width and height of the bitmap image.
Listing 3. Compute the window dimensions.
if(width % 4 == 0){
windowWidth = width;
}else{
windowWidth = (width/4)*4 + 4;
}//end else
if(windowWidth < 108){
windowWidth = 108;
}//end if
//Make the height sufficient to contain two copies of
// the image, one above the other.
windowHeight = 2 * height;
|